pydit.wrangling.groupby_text_concatenate.groupby_text¶
- pydit.wrangling.groupby_text_concatenate.groupby_text(df, key_cols, value_cols=None, target_col_name='groupby_text', field_separator=' ', row_separator='\n', unique=False)[source]¶
Groupby text column into concatenated text
- Parameters:
df (DataFrame) – Pandas DataFrame to apply the function to
key_cols (list or str) – Key columns used for grouping
value_cols (list or str or None, optional, default None) – Value colums to concatenate.
target_col_name (str, optional, default "groupby_text") – Name for the resulting column.
field_separator (str, optional, default " ") – If multiple value_cols provided then how to concatenate.
row_separator (str, optional, default newline) – Separator for the rows.
unique (bool, optional, default False) – If True, concatenate only unique values.
- Returns:
A grouped dataframe with the concatenated text.
This function does not mutate the input dataframe.
- Return type:
DataFrame