utils#




Functions#

collapse_df

Collapses results of two joined dataframes.

get_group_children

get_group_data

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

get_group_children()#

rootski.services.database.non_orm.utils.get_group_children(group_df, *child_cols, sort_col=None, ascending=True)[source]#

get_group_data()#

rootski.services.database.non_orm.utils.get_group_data(group_df: pandas.core.frame.DataFrame, *group_cols)[source]#