class_docstr: Utility class for performing a group by operation over a lazy DataFrame.
  
  Generated by calling `df.lazy().group_by(...)`.
class_docstr_tok: ["Utility","class","for","performing","a","group","by","operation","over","a","lazy","DataFrame",".","Generated","by","calling","`","df.lazy","(",")",".group_by","(","...",")","`","."]
docstr: Apply a custom/user-defined function (UDF) over the groups as a new DataFrame.
  
  .. warning::
      This method is much slower than the native expressions API.
      Only use it if you cannot implement your logic otherwise.
  
  Using this is considered an anti-pattern as it will be very slow because:
  
  - it forces the engine to materialize the whole `DataFrames` for the groups.
  - it is not parallelized
  - it blocks optimizations as the passed python function is opaque to the
    optimizer
  
  The idiomatic way to apply custom functions over multiple columns is using:
  
  `pl.struct([my_columns]).apply(lambda struct_series: ..)`
  
  Parameters
  ----------
  function
      Function to apply over each group of the `LazyFrame`.
  schema
      Schema of the output function. This has to be known statically. If the
      given schema is incorrect, this is a bug in the caller's query and may
      lead to errors. If set to None, polars assumes the schema is unchanged.
  
  Examples
  --------
  For each color group sample two rows:
  
  >>> df = pl.DataFrame(
  ...     {
  ...         "id": [0, 1, 2, 3, 4],
  ...         "color": ["red", "green", "green", "red", "red"],
  ...         "shape": ["square", "triangle", "square", "triangle", "square"],
  ...     }
  ... )
  >>> (
  ...     df.lazy()
  ...     .group_by("color")
  ...     .map_groups(lambda group_df: group_df.sample(2), schema=None)
  ...     .collect()
  ... )  # doctest: +IGNORE_RESULT
  shape: (4, 3)
  ┌─────┬───────┬──────────┐
  │ id  ┆ color ┆ shape    │
  │ --- ┆ ---   ┆ ---      │
  │ i64 ┆ str   ┆ str      │
  ╞═════╪═══════╪══════════╡
  │ 1   ┆ green ┆ triangle │
  │ 2   ┆ green ┆ square   │
  │ 4   ┆ red   ┆ square   │
  │ 3   ┆ red   ┆ triangle │
  └─────┴───────┴──────────┘
  
  It is better to implement this with an expression:
  
  >>> (
  ...     df.lazy()
  ...     .filter(pl.int_range(0, pl.count()).shuffle().over("color") < 2)
  ...     .collect()
  ... )  # doctest: +IGNORE_RESULT
docstr_tok: ["Apply","a","custom\/user-defined","function","(","UDF",")","over","the","groups","as","a","new","DataFrame",".","..","warning",":",":","This","method","is","much","slower","than","the","native","expressions","API",".","Only","use","it","if","you","can","not","implement","your","logic","otherwise",".","Using","this","is","considered","an","anti-pattern","as","it","will","be","very","slow","because",":","-","it","forces","the","engine","to","materialize","the","whole","`","DataFrames","`","for","the","groups",".","-","it","is","not","parallelized","-","it","blocks","optimizations","as","the","passed","python","function","is","opaque","to","the","optimizer","The","idiomatic","way","to","apply","custom","functions","over","multiple","columns","is","using",":","`","pl.struct","(","[","my_columns","]",")",".apply","(","lambda","struct_series",":","..",")","`","Parameters","--","--","--","--","--","function","Function","to","apply","over","each","group","of","the","`","LazyFrame","`",".","schema","Schema","of","the","output","function",".","This","has","to","be","known","statically",".","If","the","given","schema","is","incorrect",",","this","is","a","bug","in","the","caller","'s","query","and","may","lead","to","errors",".","If","set","to","None",",","polars","assumes","the","schema","is","unchanged",".","Examples","--","--","--","--","For","each","color","group","sample","two","rows",":",">",">",">","df","=","pl.DataFrame","(","...","{","...","``","id","''",":","[","0",",","1",",","2",",","3",",","4","]",",","...","``","color","''",":","[","``","red","''",",","``","green","''",",","``","green","''",",","``","red","''",",","``","red","''","]",",","...","``","shape","''",":","[","``","square","''",",","``","triangle","''",",","``","square","''",",","``","triangle","''",",","``","square","''","]",",","...","}","...",")",">",">",">","(","...","df.lazy","(",")","...",".group_by","(","``","color","''",")","...",".map_groups","(","lambda","group_df",":","group_df.sample","(","2",")",",","schema=None",")","...",".collect","(",")","...",")","#","doctest",":","+IGNORE_RESULT","shape",":","(","4",",","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\u2510","\u2502","id","\u2506","color","\u2506","shape","\u2502","\u2502","--","-","\u2506","--","-","\u2506","--","-","\u2502","\u2502","i64","\u2506","str","\u2506","str","\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\u2561","\u2502","1","\u2506","green","\u2506","triangle","\u2502","\u2502","2","\u2506","green","\u2506","square","\u2502","\u2502","4","\u2506","red","\u2506","square","\u2502","\u2502","3","\u2506","red","\u2506","triangle","\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\u2518","It","is","better","to","implement","this","with","an","expression",":",">",">",">","(","...","df.lazy","(",")","...",".filter","(","pl.int_range","(","0",",","pl.count","(",")",")",".shuffle","(",")",".over","(","``","color","''",")","<","2",")","...",".collect","(",")","...",")","#","doctest",":","+IGNORE_RESULT"]
code: def map_groups(
      self,
      function: Callable[[DataFrame], DataFrame],
      schema: SchemaDict | None,
  ) -> LazyFrame:
      """
      Apply a custom/user-defined function (UDF) over the groups as a new DataFrame.
  
      .. warning::
          This method is much slower than the native expressions API.
          Only use it if you cannot implement your logic otherwise.
  
      Using this is considered an anti-pattern as it will be very slow because:
  
      - it forces the engine to materialize the whole `DataFrames` for the groups.
      - it is not parallelized
      - it blocks optimizations as the passed python function is opaque to the
        optimizer
  
      The idiomatic way to apply custom functions over multiple columns is using:
  
      `pl.struct([my_columns]).apply(lambda struct_series: ..)`
  
      Parameters
      ----------
      function
          Function to apply over each group of the `LazyFrame`.
      schema
          Schema of the output function. This has to be known statically. If the
          given schema is incorrect, this is a bug in the caller's query and may
          lead to errors. If set to None, polars assumes the schema is unchanged.
  
      Examples
      --------
      For each color group sample two rows:
  
      >>> df = pl.DataFrame(
      ...     {
      ...         "id": [0, 1, 2, 3, 4],
      ...         "color": ["red", "green", "green", "red", "red"],
      ...         "shape": ["square", "triangle", "square", "triangle", "square"],
      ...     }
      ... )
      >>> (
      ...     df.lazy()
      ...     .group_by("color")
      ...     .map_groups(lambda group_df: group_df.sample(2), schema=None)
      ...     .collect()
      ... )  # doctest: +IGNORE_RESULT
      shape: (4, 3)
      ┌─────┬───────┬──────────┐
      │ id  ┆ color ┆ shape    │
      │ --- ┆ ---   ┆ ---      │
      │ i64 ┆ str   ┆ str      │
      ╞═════╪═══════╪══════════╡
      │ 1   ┆ green ┆ triangle │
      │ 2   ┆ green ┆ square   │
      │ 4   ┆ red   ┆ square   │
      │ 3   ┆ red   ┆ triangle │
      └─────┴───────┴──────────┘
  
      It is better to implement this with an expression:
  
      >>> (
      ...     df.lazy()
      ...     .filter(pl.int_range(0, pl.count()).shuffle().over("color") < 2)
      ...     .collect()
      ... )  # doctest: +IGNORE_RESULT
  
      """
      return wrap_ldf(self.lgb.map_groups(function, schema))
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Callable, Iterable
  from polars import functions
  from polars.utils._parse_expr_input import parse_as_list_of_expressions
  from polars.utils._wrap import wrap_ldf
  from polars.utils.deprecation import deprecate_renamed_function
label_desc: Use image node_id 3 for calling the LazyGroupBy obj's underlying member method code with example usage: obj.map_groups(function, schema) and returns: wrap_ldf