toucan_data_sdk/utils/postprocess/waterfall.py
def _compute_start_end(df, start, end):
    """
    Compute two dataframes with value for start and end
    Args:
        totals(dataframe):

    Returns: Dataframe, Dataframe

    """
    result = {}
    time_dict = {'start': start, 'end': end}
    totals = df.groupby('date').agg({'value': sum}).reset_index()
    for time_name, time in time_dict.items():
        if not totals[totals['date'] == time['id']].empty:
            value = totals.loc[
                totals['date'] == time['id'], 'value'
            ].values[0]
        else:
            value = 0
        result[time_name] = pd.DataFrame([{
            'value': value,
            'label': time['label'],
            'groups': time['label']
        }])
    return result['start'], result['end']
def _compute_start_end(df, start, end):
    """
    Compute two dataframes with value for start and end
    Args:
        totals(dataframe):

    Returns: Dataframe, Dataframe

    """
    result = {}
    time_dict = {'start': start, 'end': end}
    totals = df.groupby('date').agg({'value': sum}).reset_index()
    for time_name, time in time_dict.items():
        if not totals[totals['date'] == time['id']].empty:
            value = totals.loc[
                totals['date'] == time['id'], 'value'
            ].values[0]
        else:
            value = 0
        result[time_name] = pd.DataFrame([{
            'value': value,
            'label': time['label'],
            'groups': time['label']
        }])
    return result['start'], result['end']
def _compute_start_end ( df , start , end ) : result = { } time_dict = { 'start' : start , 'end' : end } totals = df . groupby ( 'date' ) . agg ( { 'value' : sum } ) . reset_index ( ) for time_name , time in time_dict . items ( ) : if not totals [ totals [ 'date' ] == time [ 'id' ] ] . empty : value = totals . loc [ totals [ 'date' ] == time [ 'id' ] , 'value' ] . values [ 0 ] else : value = 0 result [ time_name ] = pd . DataFrame ( [ { 'value' : value , 'label' : time [ 'label' ] , 'groups' : time [ 'label' ] } ] ) return result [ 'start' ] , result [ 'end' ]
Compute two dataframes with value for start and end
    Args:
        totals(dataframe):

    Returns: Dataframe, Dataframe
Compute two dataframes with value for start and end Args : totals ( dataframe ) :