示例#1
0
def clients_closed(country, start=None, end=None, f=None, interval='month'):
    g = [] if f is None else deepcopy(f)
    g.append(Q('term', doctype='client'))
    return _people_closed.df(country,
                             start=start,
                             end=end,
                             f=g,
                             interval=interval)
示例#2
0
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
示例#3
0
def people_closed(country, start=None, end=None, f=None, interval='month'):
    return _people_closed.df(country,
                             start=start,
                             end=end,
                             f=f,
                             interval=interval)