class_docstr: Starts a new GroupBy operation.
class_docstr_tok: ["Starts","a","new","GroupBy","operation","."]
docstr: Compute aggregations for each group of a group by operation.
  
  Parameters
  ----------
  *aggs
      Aggregations to compute for each group of the group by operation,
      specified as positional arguments.
      Accepts expression input. Strings are parsed as column names.
  **named_aggs
      Additional aggregations, specified as keyword arguments.
      The resulting columns will be renamed to the keyword used.
  
  Examples
  --------
  Compute the aggregation of the columns for each group.
  
  >>> df = pl.DataFrame(
  ...     {
  ...         "a": ["a", "b", "a", "b", "c"],
  ...         "b": [1, 2, 1, 3, 3],
  ...         "c": [5, 4, 3, 2, 1],
  ...     }
  ... )
  >>> df.group_by("a").agg(pl.col("b"), pl.col("c"))  # doctest: +IGNORE_RESULT
  shape: (3, 3)
  ┌─────┬───────────┬───────────┐
  │ a   ┆ b         ┆ c         │
  │ --- ┆ ---       ┆ ---       │
  │ str ┆ list[i64] ┆ list[i64] │
  ╞═════╪═══════════╪═══════════╡
  │ a   ┆ [1, 1]    ┆ [5, 3]    │
  ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
  │ b   ┆ [2, 3]    ┆ [4, 2]    │
  ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
  │ c   ┆ [3]       ┆ [1]       │
  └─────┴───────────┴───────────┘
  
  Compute the sum of a column for each group.
  
  >>> df.group_by("a").agg(pl.col("b").sum())  # doctest: +IGNORE_RESULT
  shape: (3, 2)
  ┌─────┬─────┐
  │ a   ┆ b   │
  │ --- ┆ --- │
  │ str ┆ i64 │
  ╞═════╪═════╡
  │ a   ┆ 2   │
  │ b   ┆ 5   │
  │ c   ┆ 3   │
  └─────┴─────┘
  
  Compute multiple aggregates at once by passing a list of expressions.
  
  >>> df.group_by("a").agg([pl.sum("b"), pl.mean("c")])  # doctest: +IGNORE_RESULT
  shape: (3, 3)
  ┌─────┬─────┬─────┐
  │ a   ┆ b   ┆ c   │
  │ --- ┆ --- ┆ --- │
  │ str ┆ i64 ┆ f64 │
  ╞═════╪═════╪═════╡
  │ c   ┆ 3   ┆ 1.0 │
  │ a   ┆ 2   ┆ 4.0 │
  │ b   ┆ 5   ┆ 3.0 │
  └─────┴─────┴─────┘
  
  Or use positional arguments to compute multiple aggregations in the same way.
  
  >>> df.group_by("a").agg(
  ...     pl.sum("b").name.suffix("_sum"),
  ...     (pl.col("c") ** 2).mean().name.suffix("_mean_squared"),
  ... )  # doctest: +IGNORE_RESULT
  shape: (3, 3)
  ┌─────┬───────┬────────────────┐
  │ a   ┆ b_sum ┆ c_mean_squared │
  │ --- ┆ ---   ┆ ---            │
  │ str ┆ i64   ┆ f64            │
  ╞═════╪═══════╪════════════════╡
  │ a   ┆ 2     ┆ 17.0           │
  │ c   ┆ 3     ┆ 1.0            │
  │ b   ┆ 5     ┆ 10.0           │
  └─────┴───────┴────────────────┘
  
  Use keyword arguments to easily name your expression inputs.
  
  >>> df.group_by("a").agg(
  ...     b_sum=pl.sum("b"),
  ...     c_mean_squared=(pl.col("c") ** 2).mean(),
  ... )  # doctest: +IGNORE_RESULT
  shape: (3, 3)
  ┌─────┬───────┬────────────────┐
  │ a   ┆ b_sum ┆ c_mean_squared │
  │ --- ┆ ---   ┆ ---            │
  │ str ┆ i64   ┆ f64            │
  ╞═════╪═══════╪════════════════╡
  │ a   ┆ 2     ┆ 17.0           │
  │ c   ┆ 3     ┆ 1.0            │
  │ b   ┆ 5     ┆ 10.0           │
  └─────┴───────┴────────────────┘
docstr_tok: ["Compute","aggregations","for","each","group","of","a","group","by","operation",".","Parameters","--","--","--","--","--","*","aggs","Aggregations","to","compute","for","each","group","of","the","group","by","operation",",","specified","as","positional","arguments",".","Accepts","expression","input",".","Strings","are","parsed","as","column","names",".","*","*","named_aggs","Additional","aggregations",",","specified","as","keyword","arguments",".","The","resulting","columns","will","be","renamed","to","the","keyword","used",".","Examples","--","--","--","--","Compute","the","aggregation","of","the","columns","for","each","group",".",">",">",">","df","=","pl.DataFrame","(","...","{","...","``","a","''",":","[","``","a","''",",","``","b","''",",","``","a","''",",","``","b","''",",","``","c","''","]",",","...","``","b","''",":","[","1",",","2",",","1",",","3",",","3","]",",","...","``","c","''",":","[","5",",","4",",","3",",","2",",","1","]",",","...","}","...",")",">",">",">","df.group_by","(","``","a","''",")",".agg","(","pl.col","(","``","b","''",")",",","pl.col","(","``","c","''",")",")","#","doctest",":","+IGNORE_RESULT","shape",":","(","3",",","3",")","\u250c\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502","a","\u2506","b","\u2506","c","\u2502","\u2502","--","-","\u2506","--","-","\u2506","--","-","\u2502","\u2502","str","\u2506","list","[","i64","]","\u2506","list","[","i64","]","\u2502","\u255e\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561","\u2502","a","\u2506","[","1",",","1","]","\u2506","[","5",",","3","]","\u2502","\u251c\u254c\u254c\u254c\u254c\u254c\u253c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u253c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u2524","\u2502","b","\u2506","[","2",",","3","]","\u2506","[","4",",","2","]","\u2502","\u251c\u254c\u254c\u254c\u254c\u254c\u253c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u253c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u254c\u2524","\u2502","c","\u2506","[","3","]","\u2506","[","1","]","\u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518","Compute","the","sum","of","a","column","for","each","group",".",">",">",">","df.group_by","(","``","a","''",")",".agg","(","pl.col","(","``","b","''",")",".sum","(",")",")","#","doctest",":","+IGNORE_RESULT","shape",":","(","3",",","2",")","\u250c\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2510","\u2502","a","\u2506","b","\u2502","\u2502","--","-","\u2506","--","-","\u2502","\u2502","str","\u2506","i64","\u2502","\u255e\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2561","\u2502","a","\u2506","2","\u2502","\u2502","b","\u2506","5","\u2502","\u2502","c","\u2506","3","\u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2518","Compute","multiple","aggregates","at","once","by","passing","a","list","of","expressions",".",">",">",">","df.group_by","(","``","a","''",")",".agg","(","[","pl.sum","(","``","b","''",")",",","pl.mean","(","``","c","''",")","]",")","#","doctest",":","+IGNORE_RESULT","shape",":","(","3",",","3",")","\u250c\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2510","\u2502","a","\u2506","b","\u2506","c","\u2502","\u2502","--","-","\u2506","--","-","\u2506","--","-","\u2502","\u2502","str","\u2506","i64","\u2506","f64","\u2502","\u255e\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2561","\u2502","c","\u2506","3","\u2506","1.0","\u2502","\u2502","a","\u2506","2","\u2506","4.0","\u2502","\u2502","b","\u2506","5","\u2506","3.0","\u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2518","Or","use","positional","arguments","to","compute","multiple","aggregations","in","the","same","way",".",">",">",">","df.group_by","(","``","a","''",")",".agg","(","...","pl.sum","(","``","b","''",")",".name.suffix","(","``","_sum","''",")",",","...","(","pl.col","(","``","c","''",")","*","*","2",")",".mean","(",")",".name.suffix","(","``","_mean_squared","''",")",",","...",")","#","doctest",":","+IGNORE_RESULT","shape",":","(","3",",","3",")","\u250c\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502","a","\u2506","b_sum","\u2506","c_mean_squared","\u2502","\u2502","--","-","\u2506","--","-","\u2506","--","-","\u2502","\u2502","str","\u2506","i64","\u2506","f64","\u2502","\u255e\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561","\u2502","a","\u2506","2","\u2506","17.0","\u2502","\u2502","c","\u2506","3","\u2506","1.0","\u2502","\u2502","b","\u2506","5","\u2506","10.0","\u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518","Use","keyword","arguments","to","easily","name","your","expression","inputs",".",">",">",">","df.group_by","(","``","a","''",")",".agg","(","...","b_sum=pl.sum","(","``","b","''",")",",","...","c_mean_squared=","(","pl.col","(","``","c","''",")","*","*","2",")",".mean","(",")",",","...",")","#","doctest",":","+IGNORE_RESULT","shape",":","(","3",",","3",")","\u250c\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502","a","\u2506","b_sum","\u2506","c_mean_squared","\u2502","\u2502","--","-","\u2506","--","-","\u2506","--","-","\u2502","\u2502","str","\u2506","i64","\u2506","f64","\u2502","\u255e\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561","\u2502","a","\u2506","2","\u2506","17.0","\u2502","\u2502","c","\u2506","3","\u2506","1.0","\u2502","\u2502","b","\u2506","5","\u2506","10.0","\u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"]
code: def agg(
      self,
      *aggs: IntoExpr | Iterable[IntoExpr],
      **named_aggs: IntoExpr,
  ) -> DataFrame:
      """
      Compute aggregations for each group of a group by operation.
  
      Parameters
      ----------
      *aggs
          Aggregations to compute for each group of the group by operation,
          specified as positional arguments.
          Accepts expression input. Strings are parsed as column names.
      **named_aggs
          Additional aggregations, specified as keyword arguments.
          The resulting columns will be renamed to the keyword used.
  
      Examples
      --------
      Compute the aggregation of the columns for each group.
  
      >>> df = pl.DataFrame(
      ...     {
      ...         "a": ["a", "b", "a", "b", "c"],
      ...         "b": [1, 2, 1, 3, 3],
      ...         "c": [5, 4, 3, 2, 1],
      ...     }
      ... )
      >>> df.group_by("a").agg(pl.col("b"), pl.col("c"))  # doctest: +IGNORE_RESULT
      shape: (3, 3)
      ┌─────┬───────────┬───────────┐
      │ a   ┆ b         ┆ c         │
      │ --- ┆ ---       ┆ ---       │
      │ str ┆ list[i64] ┆ list[i64] │
      ╞═════╪═══════════╪═══════════╡
      │ a   ┆ [1, 1]    ┆ [5, 3]    │
      ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
      │ b   ┆ [2, 3]    ┆ [4, 2]    │
      ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
      │ c   ┆ [3]       ┆ [1]       │
      └─────┴───────────┴───────────┘
  
      Compute the sum of a column for each group.
  
      >>> df.group_by("a").agg(pl.col("b").sum())  # doctest: +IGNORE_RESULT
      shape: (3, 2)
      ┌─────┬─────┐
      │ a   ┆ b   │
      │ --- ┆ --- │
      │ str ┆ i64 │
      ╞═════╪═════╡
      │ a   ┆ 2   │
      │ b   ┆ 5   │
      │ c   ┆ 3   │
      └─────┴─────┘
  
      Compute multiple aggregates at once by passing a list of expressions.
  
      >>> df.group_by("a").agg([pl.sum("b"), pl.mean("c")])  # doctest: +IGNORE_RESULT
      shape: (3, 3)
      ┌─────┬─────┬─────┐
      │ a   ┆ b   ┆ c   │
      │ --- ┆ --- ┆ --- │
      │ str ┆ i64 ┆ f64 │
      ╞═════╪═════╪═════╡
      │ c   ┆ 3   ┆ 1.0 │
      │ a   ┆ 2   ┆ 4.0 │
      │ b   ┆ 5   ┆ 3.0 │
      └─────┴─────┴─────┘
  
      Or use positional arguments to compute multiple aggregations in the same way.
  
      >>> df.group_by("a").agg(
      ...     pl.sum("b").name.suffix("_sum"),
      ...     (pl.col("c") ** 2).mean().name.suffix("_mean_squared"),
      ... )  # doctest: +IGNORE_RESULT
      shape: (3, 3)
      ┌─────┬───────┬────────────────┐
      │ a   ┆ b_sum ┆ c_mean_squared │
      │ --- ┆ ---   ┆ ---            │
      │ str ┆ i64   ┆ f64            │
      ╞═════╪═══════╪════════════════╡
      │ a   ┆ 2     ┆ 17.0           │
      │ c   ┆ 3     ┆ 1.0            │
      │ b   ┆ 5     ┆ 10.0           │
      └─────┴───────┴────────────────┘
  
      Use keyword arguments to easily name your expression inputs.
  
      >>> df.group_by("a").agg(
      ...     b_sum=pl.sum("b"),
      ...     c_mean_squared=(pl.col("c") ** 2).mean(),
      ... )  # doctest: +IGNORE_RESULT
      shape: (3, 3)
      ┌─────┬───────┬────────────────┐
      │ a   ┆ b_sum ┆ c_mean_squared │
      │ --- ┆ ---   ┆ ---            │
      │ str ┆ i64   ┆ f64            │
      ╞═════╪═══════╪════════════════╡
      │ a   ┆ 2     ┆ 17.0           │
      │ c   ┆ 3     ┆ 1.0            │
      │ b   ┆ 5     ┆ 10.0           │
      └─────┴───────┴────────────────┘
  
      """
      return (
          self.df.lazy()
          .group_by(
              self.by, *self.more_by, maintain_order=self.maintain_order
          )
          .agg(*aggs, **named_aggs)
          .collect(no_optimization=True)
      )
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Callable, Iterable, Iterator
  import polars._reexport
  from polars import functions
  from polars.utils.convert import _timedelta_to_pl_duration
  from polars.utils.deprecation import deprecate_renamed_function
label_desc: Use image node_id 4 for calling the GroupBy obj's underlying member method code with example usage: obj.agg() and returns: self