def employees_opened(country, start=None, end=None, f=None, interval='month'): g = [] if f is None else deepcopy(f) g.append(Q('term', doctype='employee')) return _people_opened.df(country, start=start, end=end, f=g, interval=interval)
def df_start(country, start=None, end=None, f=None, interval='month'): if f is None: f = [] open = open_now(country, end=end, f=f) opened = people_opened.df(country, start=start, end=end, f=f, interval=interval) closed = people_closed.df(country, start=start, end=end, f=f, interval=interval) if opened.empty or closed.empty: return DataFrame(columns=['start']) merged = opened.merge(closed, on='date', how='outer').sort_index() merged = merged.fillna(0).astype('int64') df = DataFrame(index=merged.index, columns=['start']) if merged.empty: return DataFrame(columns=['start']) rev_idx = merged.index.tolist() rev_idx.reverse() for i in range(len(rev_idx)): if i == 0: df.loc[rev_idx[i]] = (open - merged['opened'].get(rev_idx[i], 0) + merged['closed'].get(rev_idx[i], 0)) elif i > 0: df.loc[rev_idx[i]] = (df.loc[rev_idx[i - 1]] - merged['opened'].get(rev_idx[i], 0) + merged['closed'].get(rev_idx[i], 0)) return df
def people_opened(country, start=None, end=None, f=None, interval='month'): return _people_opened.df(country, start=start, end=end, f=f, interval=interval)