> ## 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.

## Parameters

**df** `DataFrame` *required*

The dataframe with flat data

**group\_by\_col** `str` *required*

The column to group the data by

**output\_path** `Path | str | None` (default: None)

Optional path to write the grouped data to. If not specified, data won't be written anywhere

## Returns

Dataframe in grouped format

## Examples

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

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