polars.internals.frame.GroupBy.get_group

GroupBy.get_group(group_value: Union[Any, Tuple[Any]]) polars.internals.frame.DF

Select a single group as a new DataFrame.

Deprecated since version 0.13.32: Please use partition_by

Parameters
group_value

Group to select.

Examples

>>> df = pl.DataFrame(
...     {
...         "foo": ["one", "one", "one", "two", "two", "two"],
...         "bar": ["A", "B", "C", "A", "B", "C"],
...         "baz": [1, 2, 3, 4, 5, 6],
...     }
... )
>>> df.groupby("foo").get_group("one")
shape: (3, 3)
┌─────┬─────┬─────┐
│ foo ┆ bar ┆ baz │
│ --- ┆ --- ┆ --- │
│ str ┆ str ┆ i64 │
╞═════╪═════╪═════╡
│ one ┆ A   ┆ 1   │
├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
│ one ┆ B   ┆ 2   │
├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
│ one ┆ C   ┆ 3   │
└─────┴─────┴─────┘