> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fiddler.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# group_by

> Group the events by a column. Use this method to form the grouped data for ranking models.

Group the events by a column. Use this method to form the grouped data for ranking models.

## Parameters

<ParamField path="df" type="DataFrame" required={true}>
  The dataframe with flat data
</ParamField>

<ParamField path="group_by_col" type="str" required={true}>
  The column to group the data by
</ParamField>

<ParamField path="output_path" type="Path | str | None" required={false} default="None">
  Optional path to write the grouped data to. If not specified, data won't be written anywhere
</ParamField>

## Returns

<ResponseField type="pd.DataFrame">
  Dataframe in grouped format
</ResponseField>

## Examples

```python theme={null}
COLUMN_NAME = 'col_2'

grouped_df = group_by(df=df, group_by_col=COLUMN_NAME)
```
