ó
    œþöh¢d  ã                  óô   • S SK Jr  S SKJrJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJrJr  \(       a?  S SKrS SKJr  S S	KJrJr  S S
KJr  S SKJrJrJr  \R4                  S:¼  a  S SKJ	r	  OS SKJ	r	   " S S5      rg)é    )Úannotations)ÚTYPE_CHECKINGÚCallable)Ú	functions)Ú
deprecated)Úparse_into_list_of_expressions)Úwrap_dfÚwrap_ldfN)ÚIterable)Ú	DataFrameÚ	LazyFrame)ÚPyLazyGroupBy)ÚIntoExprÚQuantileMethodÚ
SchemaDict)é   é   c                  ó  • \ rS rSrSrSS jr      SS jr      SS jrSSS jjrSSS jjr	SS jr
SSS
 jjr\" S5      SS j5       rSS jrSS jrSS jrSS jrSS jrSS jrSS jr S     S S jjrSS jrSrg	)!ÚLazyGroupByé   z{
Utility class for performing a group by operation over a lazy DataFrame.

Generated by calling `df.lazy().group_by(...)`.
c                ó   • Xl         g ©N©Úlgb)Úselfr   s     ÚS/home/james-whalen/.local/lib/python3.13/site-packages/polars/lazyframe/group_by.pyÚ__init__ÚLazyGroupBy.__init__   s   € Øó    c                ó¸   • U(       a%  [        US   [        5      (       a  Sn[        U5      e[        U0 UD6n[	        U R
                  R                  U5      5      $ )u…  
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.

>>> ldf = pl.DataFrame(
...     {
...         "a": ["a", "b", "a", "b", "c"],
...         "b": [1, 2, 1, 3, 3],
...         "c": [5, 4, 3, 2, 1],
...     }
... ).lazy()
>>> ldf.group_by("a").agg(
...     [pl.col("b"), pl.col("c")]
... ).collect()  # 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.

>>> ldf.group_by("a").agg(
...     pl.col("b").sum()
... ).collect()  # 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.

>>> ldf.group_by("a").agg(
...     [pl.sum("b"), pl.mean("c")]
... ).collect()  # 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.

>>> ldf.group_by("a").agg(
...     pl.sum("b").name.suffix("_sum"),
...     (pl.col("c") ** 2).mean().name.suffix("_mean_squared"),
... ).collect()  # 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.

>>> ldf.group_by("a").agg(
...     b_sum=pl.sum("b"),
...     c_mean_squared=(pl.col("c") ** 2).mean(),
... ).collect()  # 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           â”‚
â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
r   z“specifying aggregations as a dictionary is not supported

Try unpacking the dictionary to take advantage of the keyword syntax of the `agg` method.)Ú
isinstanceÚdictÚ	TypeErrorr   r
   r   Úagg)r   ÚaggsÚ
named_aggsÚmsgÚpyexprss        r   r$   ÚLazyGroupBy.agg"   sU   € ö^ ”J˜t A™w¬×-Ñ-ð(ð ô
 ˜C“.Ð ä0°$ÐE¸*ÑEˆÜ˜Ÿ™Ÿ™ WÓ-Ó.Ð.r   c                óV   ^• [        U R                  R                  U4S jU5      5      $ )u  
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(pl.len()).shuffle().over("color") < 2
... ).collect()  # doctest: +IGNORE_RESULT
c                ó:   >• T" [        U 5      5      R                  $ r   )r	   Ú_df)ÚdfÚfunctions    €r   Ú<lambda>Ú(LazyGroupBy.map_groups.<locals>.<lambda>à   s   ø€ ©8´G¸B³KÓ+@×+DÒ+Dr   )r
   r   Ú
map_groups)r   r.   Úschemas    ` r   r1   ÚLazyGroupBy.map_groupsœ   s(   ø€ ôF ØH‰H×ÑÔ DÀfÓMó
ð 	
r   c                óJ   • [        U R                  R                  U5      5      $ )u&  
Get the first `n` rows of each group.

Parameters
----------
n
    Number of rows to return.

Examples
--------
>>> df = pl.DataFrame(
...     {
...         "letters": ["c", "c", "a", "c", "a", "b"],
...         "nrs": [1, 2, 3, 4, 5, 6],
...     }
... )
>>> df
shape: (6, 2)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
â”‚ letters â”† nrs â”‚
â”‚ ---     â”† --- â”‚
â”‚ str     â”† i64 â”‚
â•žâ•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•¡
â”‚ c       â”† 1   â”‚
â”‚ c       â”† 2   â”‚
â”‚ a       â”† 3   â”‚
â”‚ c       â”† 4   â”‚
â”‚ a       â”† 5   â”‚
â”‚ b       â”† 6   â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
>>> df.group_by("letters").head(2).sort("letters")
shape: (5, 2)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
â”‚ letters â”† nrs â”‚
â”‚ ---     â”† --- â”‚
â”‚ str     â”† i64 â”‚
â•žâ•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•¡
â”‚ a       â”† 3   â”‚
â”‚ a       â”† 5   â”‚
â”‚ b       â”† 6   â”‚
â”‚ c       â”† 1   â”‚
â”‚ c       â”† 2   â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
)r
   r   Úhead©r   Úns     r   r5   ÚLazyGroupBy.headã   ó   € ôZ ˜Ÿ™Ÿ™ aÓ(Ó)Ð)r   c                óJ   • [        U R                  R                  U5      5      $ )u&  
Get the last `n` rows of each group.

Parameters
----------
n
    Number of rows to return.

Examples
--------
>>> df = pl.DataFrame(
...     {
...         "letters": ["c", "c", "a", "c", "a", "b"],
...         "nrs": [1, 2, 3, 4, 5, 6],
...     }
... )
>>> df
shape: (6, 2)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
â”‚ letters â”† nrs â”‚
â”‚ ---     â”† --- â”‚
â”‚ str     â”† i64 â”‚
â•žâ•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•¡
â”‚ c       â”† 1   â”‚
â”‚ c       â”† 2   â”‚
â”‚ a       â”† 3   â”‚
â”‚ c       â”† 4   â”‚
â”‚ a       â”† 5   â”‚
â”‚ b       â”† 6   â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
>>> df.group_by("letters").tail(2).sort("letters")
 shape: (5, 2)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
â”‚ letters â”† nrs â”‚
â”‚ ---     â”† --- â”‚
â”‚ str     â”† i64 â”‚
â•žâ•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•¡
â”‚ a       â”† 3   â”‚
â”‚ a       â”† 5   â”‚
â”‚ b       â”† 6   â”‚
â”‚ c       â”† 2   â”‚
â”‚ c       â”† 4   â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
)r
   r   Útailr6   s     r   r;   ÚLazyGroupBy.tail  r9   r   c                óJ   • U R                  [        R                  " 5       5      $ )u6  
Aggregate the groups into Series.

Examples
--------
>>> ldf = pl.DataFrame(
...     {
...         "a": ["one", "two", "one", "two"],
...         "b": [1, 2, 3, 4],
...     }
... ).lazy()
>>> ldf.group_by("a", maintain_order=True).all().collect()
shape: (2, 2)
â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
â”‚ a   â”† b         â”‚
â”‚ --- â”† ---       â”‚
â”‚ str â”† list[i64] â”‚
â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•¡
â”‚ one â”† [1, 3]    â”‚
â”‚ two â”† [2, 4]    â”‚
â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
)r$   ÚFÚall©r   s    r   r?   ÚLazyGroupBy.allA  s   € ð. x‰xœŸš›Ó Ð r   Nc                óv   • [         R                  " 5       nUb  UR                  U5      nU R                  U5      $ )uŸ  
Return the number of rows in each group.

Parameters
----------
name
    Assign a name to the resulting column; if unset, defaults to "len".

Examples
--------
>>> lf = pl.LazyFrame({"a": ["Apple", "Apple", "Orange"], "b": [1, None, 2]})
>>> lf.group_by("a").len().collect()  # doctest: +IGNORE_RESULT
shape: (2, 2)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
â”‚ a      â”† len â”‚
â”‚ ---    â”† --- â”‚
â”‚ str    â”† u32 â”‚
â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•¡
â”‚ Apple  â”† 2   â”‚
â”‚ Orange â”† 1   â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
>>> lf.group_by("a").len(name="n").collect()  # doctest: +IGNORE_RESULT
shape: (2, 2)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
â”‚ a      â”† n   â”‚
â”‚ ---    â”† --- â”‚
â”‚ str    â”† u32 â”‚
â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•¡
â”‚ Apple  â”† 2   â”‚
â”‚ Orange â”† 1   â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
)r>   ÚlenÚaliasr$   )r   ÚnameÚlen_exprs      r   rC   ÚLazyGroupBy.lenZ  s3   € ôB —5’5“7ˆØÑØ—~‘~ dÓ+ˆHØx‰x˜Ó!Ð!r   z&`count` was renamed; use `len` insteadc                óh   • U R                  [        R                  " 5       R                  S5      5      $ )u°  
Return the number of rows in each group.

.. deprecated:: 0.20.5
    This method has been renamed to :func:`LazyGroupBy.len`.

Rows containing null values count towards the total.

Examples
--------
>>> lf = pl.LazyFrame(
...     {
...         "a": ["Apple", "Apple", "Orange"],
...         "b": [1, None, 2],
...     }
... )
>>> lf.group_by("a").count().collect()  # doctest: +SKIP
shape: (2, 2)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”
â”‚ a      â”† count â”‚
â”‚ ---    â”† ---   â”‚
â”‚ str    â”† u32   â”‚
â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•¡
â”‚ Apple  â”† 2     â”‚
â”‚ Orange â”† 1     â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”˜
Úcount)r$   r>   rC   rD   r@   s    r   rI   ÚLazyGroupBy.count€  s"   € ð: x‰xœŸš›Ÿ™ gÓ.Ó/Ð/r   c                óf   • U R                  [        R                  " 5       R                  5       5      $ )u­  
Aggregate the first values in the group.

Examples
--------
>>> ldf = pl.DataFrame(
...     {
...         "a": [1, 2, 2, 3, 4, 5],
...         "b": [0.5, 0.5, 4, 10, 13, 14],
...         "c": [True, True, True, False, False, True],
...         "d": ["Apple", "Orange", "Apple", "Apple", "Banana", "Banana"],
...     }
... ).lazy()
>>> ldf.group_by("d", maintain_order=True).first().collect()
shape: (3, 4)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”
â”‚ d      â”† a   â”† b    â”† c     â”‚
â”‚ ---    â”† --- â”† ---  â”† ---   â”‚
â”‚ str    â”† i64 â”† f64  â”† bool  â”‚
â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•¡
â”‚ Apple  â”† 1   â”† 0.5  â”† true  â”‚
â”‚ Orange â”† 2   â”† 0.5  â”† true  â”‚
â”‚ Banana â”† 4   â”† 13.0 â”† false â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”˜
)r$   r>   r?   Úfirstr@   s    r   rL   ÚLazyGroupBy.firstŸ  s   € ð4 x‰xœŸš›Ÿ™›Ó(Ð(r   c                óf   • U R                  [        R                  " 5       R                  5       5      $ )u«  
Aggregate the last values in the group.

Examples
--------
>>> ldf = pl.DataFrame(
...     {
...         "a": [1, 2, 2, 3, 4, 5],
...         "b": [0.5, 0.5, 4, 10, 14, 13],
...         "c": [True, True, True, False, False, True],
...         "d": ["Apple", "Orange", "Apple", "Apple", "Banana", "Banana"],
...     }
... ).lazy()
>>> ldf.group_by("d", maintain_order=True).last().collect()
shape: (3, 4)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”
â”‚ d      â”† a   â”† b    â”† c     â”‚
â”‚ ---    â”† --- â”† ---  â”† ---   â”‚
â”‚ str    â”† i64 â”† f64  â”† bool  â”‚
â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•¡
â”‚ Apple  â”† 3   â”† 10.0 â”† false â”‚
â”‚ Orange â”† 2   â”† 0.5  â”† true  â”‚
â”‚ Banana â”† 5   â”† 13.0 â”† true  â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”˜
)r$   r>   r?   Úlastr@   s    r   rO   ÚLazyGroupBy.last»  ó   € ð4 x‰xœŸš›Ÿ™›Ó'Ð'r   c                óf   • U R                  [        R                  " 5       R                  5       5      $ )u›  
Reduce the groups to the maximal value.

Examples
--------
>>> ldf = pl.DataFrame(
...     {
...         "a": [1, 2, 2, 3, 4, 5],
...         "b": [0.5, 0.5, 4, 10, 13, 14],
...         "c": [True, True, True, False, False, True],
...         "d": ["Apple", "Orange", "Apple", "Apple", "Banana", "Banana"],
...     }
... ).lazy()
>>> ldf.group_by("d", maintain_order=True).max().collect()
shape: (3, 4)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”
â”‚ d      â”† a   â”† b    â”† c    â”‚
â”‚ ---    â”† --- â”† ---  â”† ---  â”‚
â”‚ str    â”† i64 â”† f64  â”† bool â”‚
â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡
â”‚ Apple  â”† 3   â”† 10.0 â”† true â”‚
â”‚ Orange â”† 2   â”† 0.5  â”† true â”‚
â”‚ Banana â”† 5   â”† 14.0 â”† true â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
)r$   r>   r?   Úmaxr@   s    r   rS   ÚLazyGroupBy.max×  ó   € ð4 x‰xœŸš›Ÿ™›Ó&Ð&r   c                óf   • U R                  [        R                  " 5       R                  5       5      $ )u  
Reduce the groups to the mean values.

Examples
--------
>>> ldf = pl.DataFrame(
...     {
...         "a": [1, 2, 2, 3, 4, 5],
...         "b": [0.5, 0.5, 4, 10, 13, 14],
...         "c": [True, True, True, False, False, True],
...         "d": ["Apple", "Orange", "Apple", "Apple", "Banana", "Banana"],
...     }
... ).lazy()
>>> ldf.group_by("d", maintain_order=True).mean().collect()
shape: (3, 4)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
â”‚ d      â”† a   â”† b        â”† c        â”‚
â”‚ ---    â”† --- â”† ---      â”† ---      â”‚
â”‚ str    â”† f64 â”† f64      â”† f64      â”‚
â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•¡
â”‚ Apple  â”† 2.0 â”† 4.833333 â”† 0.666667 â”‚
â”‚ Orange â”† 2.0 â”† 0.5      â”† 1.0      â”‚
â”‚ Banana â”† 4.5 â”† 13.5     â”† 0.5      â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
)r$   r>   r?   Úmeanr@   s    r   rW   ÚLazyGroupBy.meanó  rQ   r   c                óf   • U R                  [        R                  " 5       R                  5       5      $ )uÅ  
Return the median per group.

Examples
--------
>>> ldf = pl.DataFrame(
...     {
...         "a": [1, 2, 2, 3, 4, 5],
...         "b": [0.5, 0.5, 4, 10, 13, 14],
...         "d": ["Apple", "Banana", "Apple", "Apple", "Banana", "Banana"],
...     }
... ).lazy()
>>> ldf.group_by("d", maintain_order=True).median().collect()
shape: (2, 3)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”
â”‚ d      â”† a   â”† b    â”‚
â”‚ ---    â”† --- â”† ---  â”‚
â”‚ str    â”† f64 â”† f64  â”‚
â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡
â”‚ Apple  â”† 2.0 â”† 4.0  â”‚
â”‚ Banana â”† 4.0 â”† 13.0 â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
)r$   r>   r?   Úmedianr@   s    r   rZ   ÚLazyGroupBy.median  s    € ð0 x‰xœŸš›Ÿ™Ó(Ó)Ð)r   c                óf   • U R                  [        R                  " 5       R                  5       5      $ )uª  
Reduce the groups to the minimal value.

Examples
--------
>>> ldf = pl.DataFrame(
...     {
...         "a": [1, 2, 2, 3, 4, 5],
...         "b": [0.5, 0.5, 4, 10, 13, 14],
...         "c": [True, True, True, False, False, True],
...         "d": ["Apple", "Orange", "Apple", "Apple", "Banana", "Banana"],
...     }
... ).lazy()
>>> ldf.group_by("d", maintain_order=True).min().collect()
shape: (3, 4)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”
â”‚ d      â”† a   â”† b    â”† c     â”‚
â”‚ ---    â”† --- â”† ---  â”† ---   â”‚
â”‚ str    â”† i64 â”† f64  â”† bool  â”‚
â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•¡
â”‚ Apple  â”† 1   â”† 0.5  â”† false â”‚
â”‚ Orange â”† 2   â”† 0.5  â”† true  â”‚
â”‚ Banana â”† 4   â”† 13.0 â”† false â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”˜
)r$   r>   r?   Úminr@   s    r   r]   ÚLazyGroupBy.min)  rU   r   c                óf   • U R                  [        R                  " 5       R                  5       5      $ )uÁ  
Count the unique values per group.

Examples
--------
>>> ldf = pl.DataFrame(
...     {
...         "a": [1, 2, 1, 3, 4, 5],
...         "b": [0.5, 0.5, 0.5, 10, 13, 14],
...         "d": ["Apple", "Banana", "Apple", "Apple", "Banana", "Banana"],
...     }
... ).lazy()
>>> ldf.group_by("d", maintain_order=True).n_unique().collect()
shape: (2, 3)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
â”‚ d      â”† a   â”† b   â”‚
â”‚ ---    â”† --- â”† --- â”‚
â”‚ str    â”† u32 â”† u32 â”‚
â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
â”‚ Apple  â”† 2   â”† 2   â”‚
â”‚ Banana â”† 3   â”† 3   â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
)r$   r>   r?   Ún_uniquer@   s    r   r`   ÚLazyGroupBy.n_uniqueE  s"   € ð0 x‰xœŸš›×(Ñ(Ó*Ó+Ð+r   c                ód   • U R                  [        R                  " 5       R                  XS95      $ )uœ  
Compute the quantile per group.

Parameters
----------
quantile
    Quantile between 0.0 and 1.0.
interpolation : {'nearest', 'higher', 'lower', 'midpoint', 'linear', 'equiprobable'}
    Interpolation method.

Examples
--------
>>> ldf = pl.DataFrame(
...     {
...         "a": [1, 2, 2, 3, 4, 5],
...         "b": [0.5, 0.5, 4, 10, 13, 14],
...         "d": ["Apple", "Orange", "Apple", "Apple", "Banana", "Banana"],
...     }
... ).lazy()
>>> ldf.group_by("d", maintain_order=True).quantile(1).collect()
shape: (3, 3)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”
â”‚ d      â”† a   â”† b    â”‚
â”‚ ---    â”† --- â”† ---  â”‚
â”‚ str    â”† f64 â”† f64  â”‚
â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡
â”‚ Apple  â”† 3.0 â”† 10.0 â”‚
â”‚ Orange â”† 2.0 â”† 0.5  â”‚
â”‚ Banana â”† 5.0 â”† 14.0 â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
)Úinterpolation)r$   r>   r?   Úquantile)r   rd   rc   s      r   rd   ÚLazyGroupBy.quantile_  s(   € ðD x‰xœŸš›×(Ñ(¨Ð(ÐOÓPÐPr   c                óf   • U R                  [        R                  " 5       R                  5       5      $ )u‚  
Reduce the groups to the sum.

Examples
--------
>>> ldf = pl.DataFrame(
...     {
...         "a": [1, 2, 2, 3, 4, 5],
...         "b": [0.5, 0.5, 4, 10, 13, 14],
...         "c": [True, True, True, False, False, True],
...         "d": ["Apple", "Orange", "Apple", "Apple", "Banana", "Banana"],
...     }
... ).lazy()
>>> ldf.group_by("d", maintain_order=True).sum().collect()
shape: (3, 4)
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
â”‚ d      â”† a   â”† b    â”† c   â”‚
â”‚ ---    â”† --- â”† ---  â”† --- â”‚
â”‚ str    â”† i64 â”† f64  â”† u32 â”‚
â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•ªâ•â•â•â•â•â•¡
â”‚ Apple  â”† 6   â”† 14.5 â”† 2   â”‚
â”‚ Orange â”† 2   â”† 0.5  â”† 1   â”‚
â”‚ Banana â”† 9   â”† 27.0 â”† 1   â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
)r$   r>   r?   Úsumr@   s    r   rg   ÚLazyGroupBy.sumƒ  rU   r   r   )r   r   ÚreturnÚNone)r%   zIntoExpr | Iterable[IntoExpr]r&   r   ri   r   )r.   z Callable[[DataFrame], DataFrame]r2   zSchemaDict | Noneri   r   )é   )r7   Úintri   r   )ri   r   r   )rE   z
str | Noneri   r   )Únearest)rd   Úfloatrc   r   ri   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r$   r1   r5   r;   r?   rC   r   rI   rL   rO   rS   rW   rZ   r]   r`   rd   rg   Ú__static_attributes__© r   r   r   r      sÚ   † ñôðx/à,ðx/ð ðx/ð 
ô	x/ðtE
à2ðE
ð "ðE
ð 
ô	E
öN-*ö^-*ô^!ö2$"ñL Ð8Ó9ó0ó :ð0ô<)ô8(ô8'ô8(ô8*ô4'ô8,ð6 @Ið"QØð"QØ.<ð"Qà	õ"Q÷H'r   r   )Ú
__future__r   Útypingr   r   Úpolarsr   r>   Úpolars._utils.deprecationr   Úpolars._utils.parser   Úpolars._utils.wrapr	   r
   ÚsysÚcollections.abcr   r   r   Úpolars._plrr   Úpolars._typingr   r   r   Úversion_infoÚwarningsÚtyping_extensionsr   ru   r   r   Ú<module>rƒ      sL   ðÝ "ç *å !Ý 0Ý >ß 0æÛÝ(ç+Ý)ßCÑCà
×Ñ˜7Ó"Þ'å0÷E
'ò E
'r   