§
    q-Phid  ã                  óä   — d dl mZ d dlmZmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ er:d dlZd dlmZ d d	lmZmZ d d
lmZmZmZ d dlmZ ej        dk    rd dlm	Z	 nd dlm	Z	  G d„ d¦  «        ZdS )é    )Úannotations)ÚTYPE_CHECKINGÚCallable)Ú	functions)Ú
deprecated)Úparse_into_list_of_expressions)Úwrap_ldfN)ÚIterable)Ú	DataFrameÚ	LazyFrame)ÚIntoExprÚQuantileMethodÚ
SchemaDict)ÚPyLazyGroupBy)é   é   c                  óÆ   — e Zd ZdZd,d„Zd-d„Zd.d„Zd/d0d„Zd/d0d„Zd1d„Z	d2d3d„Z
 ed¦  «        d1d„¦   «         Zd1d„Zd1d„Zd1d „Zd1d!„Zd1d"„Zd1d#„Zd1d$„Z	 d4d5d*„Zd1d+„ZdS )6ÚLazyGroupByz‡
    Utility class for performing a group by operation over a lazy DataFrame.

    Generated by calling `df.lazy().group_by(...)`.
    Úlgbr   ÚreturnÚNonec                ó   — || _         d S ©N)r   )Úselfr   s     úY/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/polars/lazyframe/group_by.pyÚ__init__zLazyGroupBy.__init__   s   € ØˆŒˆˆó    ÚaggsúIntoExpr | Iterable[IntoExpr]Ú
named_aggsr   r   c                óÄ   — |r,t          |d         t          ¦  «        rd}t          |¦  «        ‚t          |i |¤Ž}t	          | j                             |¦  «        ¦  «        S )uu  
        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   r   r    ÚmsgÚpyexprss        r   r%   zLazyGroupBy.agg"   sh   € ð^ ð 	!•J˜t Aœw­Ñ-Ô-ð 	!ð(ð õ
 ˜C‘.”.Ð å0°$ÐE¸*ÐEÐEˆÝ˜œŸš WÑ-Ô-Ñ.Ô.Ð.r   Úfunctionú Callable[[DataFrame], DataFrame]ÚschemaúSchemaDict | Nonec                óR   — t          | j                             ||¦  «        ¦  «        S )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
        )r	   r   Ú
map_groups)r   r(   r*   s      r   r-   zLazyGroupBy.map_groupsœ   s%   € õF ˜œ×+Ò+¨H°fÑ=Ô=Ñ>Ô>Ð>r   é   ÚnÚintc                óP   — t          | j                             |¦  «        ¦  «        S )un  
        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   r/   s     r   r2   zLazyGroupBy.headá   ó!   € õZ ˜œŸš aÑ(Ô(Ñ)Ô)Ð)r   c                óP   — t          | j                             |¦  «        ¦  «        S )un  
        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   Útailr3   s     r   r6   zLazyGroupBy.tail  r4   r   c                óN   — |                       t          j        ¦   «         ¦  «        S )uÖ  
        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   r9   zLazyGroupBy.all?  s   € ð. xŠxœ™œÑ Ô Ð r   NÚnameú
str | Nonec                ó€   — t          j        ¦   «         }||                     |¦  «        }|                      |¦  «        S )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   â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
        )r8   ÚlenÚaliasr%   )r   r;   Úlen_exprs      r   r>   zLazyGroupBy.lenX  s9   € õB ”5‘7”7ˆØÐØ—~’~ dÑ+Ô+ˆHØxŠx˜Ñ!Ô!Ð!r   z&`count` was renamed; use `len` insteadc                ót   — |                       t          j        ¦   «                              d¦  «        ¦  «        S )uh  
        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%   r8   r>   r?   r:   s    r   rB   zLazyGroupBy.count~  s(   € ð: xŠxœ™œŸš gÑ.Ô.Ñ/Ô/Ð/r   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )ue  
        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%   r8   r9   Úfirstr:   s    r   rD   zLazyGroupBy.first  s$   € ð4 xŠxœ™œŸš™œÑ(Ô(Ð(r   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )uc  
        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%   r8   r9   Úlastr:   s    r   rF   zLazyGroupBy.last¹  ó$   € ð4 xŠxœ™œŸš™œÑ'Ô'Ð'r   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )uS  
        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%   r8   r9   Úmaxr:   s    r   rI   zLazyGroupBy.maxÕ  ó$   € ð4 xŠxœ™œŸš™œÑ&Ô&Ð&r   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )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%   r8   r9   Úmeanr:   s    r   rL   zLazyGroupBy.meanñ  rG   r   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )um  
        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%   r8   r9   Úmedianr:   s    r   rN   zLazyGroupBy.median  s&   € ð0 xŠxœ™œŸšÑ(Ô(Ñ)Ô)Ð)r   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )ub  
        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%   r8   r9   Úminr:   s    r   rP   zLazyGroupBy.min'  rJ   r   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )ui  
        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%   r8   r9   Ún_uniquer:   s    r   rR   zLazyGroupBy.n_uniqueC  s(   € ð0 xŠxœ™œ×(Ò(Ñ*Ô*Ñ+Ô+Ð+r   ÚnearestÚquantileÚfloatÚinterpolationr   c                óx   — |                       t          j        ¦   «                              ||¬¦  «        ¦  «        S )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 â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
        )rV   )r%   r8   r9   rT   )r   rT   rV   s      r   rT   zLazyGroupBy.quantile]  s0   € ðD xŠxœ™œ×(Ò(¨ÀÐ(ÑOÔOÑPÔPÐPr   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )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%   r8   r9   Úsumr:   s    r   rY   zLazyGroupBy.sum  rJ   r   )r   r   r   r   )r   r   r    r   r   r   )r(   r)   r*   r+   r   r   )r.   )r/   r0   r   r   )r   r   r   )r;   r<   r   r   )rS   )rT   rU   rV   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r%   r-   r2   r6   r9   r>   r   rB   rD   rF   rI   rL   rN   rP   rR   rT   rY   © r   r   r   r      s¸  € € € € € ðð ðð ð ð ðx/ð x/ð x/ð x/ðtC?ð C?ð C?ð C?ðJ-*ð -*ð -*ð -*ð -*ð^-*ð -*ð -*ð -*ð -*ð^!ð !ð !ð !ð2$"ð $"ð $"ð $"ð $"ðL €ZÐ8Ñ9Ô9ð0ð 0ð 0ñ :Ô9ð0ð<)ð )ð )ð )ð8(ð (ð (ð (ð8'ð 'ð 'ð 'ð8(ð (ð (ð (ð8*ð *ð *ð *ð4'ð 'ð 'ð 'ð8,ð ,ð ,ð ,ð6 @Ið"Qð "Qð "Qð "Qð "QðH'ð 'ð 'ð 'ð 'ð 'r   r   )Ú
__future__r   Útypingr   r   Úpolarsr   r8   Úpolars._utils.deprecationr   Úpolars._utils.parser   Úpolars._utils.wrapr	   ÚsysÚcollections.abcr
   r   r   Úpolars._typingr   r   r   Úpolars.polarsr   Úversion_infoÚwarningsÚtyping_extensionsr   r^   r   r   ú<module>rl      sS  ðØ "Ð "Ð "Ð "Ð "Ð "à *Ð *Ð *Ð *Ð *Ð *Ð *Ð *à !Ð !Ð !Ð !Ð !Ð !Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø >Ð >Ð >Ð >Ð >Ð >Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'àð 1Ø€J€J€JØ(Ð(Ð(Ð(Ð(Ð(à+Ð+Ð+Ð+Ð+Ð+Ð+Ð+ØCÐCÐCÐCÐCÐCÐCÐCÐCÐCØ+Ð+Ð+Ð+Ð+Ð+à
Ô˜7Ò"Ð"Ø'Ð'Ð'Ð'Ð'Ð'Ð'à0Ð0Ð0Ð0Ð0Ð0ðC
'ð C
'ð C
'ð C
'ð C
'ñ C
'ô C
'ð C
'ð C
'ð C
'r   