utils#
Functions#
Collapses results of two joined dataframes. |
|
collapse_df()#
- rootski.services.database.non_orm.utils.collapse_df(df: pandas.core.frame.DataFrame, groupby_col, group_cols, child_cols, child_name, grp_sort_col=None, grp_ascending=True, ch_sort_col=None, ch_ascending=True)[source]#
Collapses results of two joined dataframes.
- Parameters
df (pd.DataFrame) – dataframe to collapse
groupby_col (str) – column name to group by and collapse
group_cols (list[str]) – list of column names to keep at the group level
grp_sort_col (str) – one of the group_cols, sort the group rows by this col
grp_ascending (bool) – sort group cols in ascending order
child_cols (list[str]) – list of columns to keep for each child in the child attribute
child_name (str) – name of the child attribute
ch_sort_col (str) – one of the child_cols, sorts children within group by this column