polars.internals.dataframe.groupby.GroupBy.agg_list#

GroupBy.agg_list() DataFrame[source]#

Aggregate the groups into Series.

Examples

>>> df = pl.DataFrame({"a": ["one", "two", "one", "two"], "b": [1, 2, 3, 4]})
>>> df.groupby("a", maintain_order=True).agg_list()
shape: (2, 2)
┌─────┬───────────┐
│ a   ┆ b         │
│ --- ┆ ---       │
│ str ┆ list[i64] │
╞═════╪═══════════╡
│ one ┆ [1, 3]    │
├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
│ two ┆ [2, 4]    │
└─────┴───────────┘