§
    q-Ph—  ã                  óD  — 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 erVd dlZd dlmZ d dlmZ d d	lmZ d d
lmZmZmZmZmZmZ ej        dk    rd dlmZ n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 G d„ d¦  «        Z G d„ d¦  «        ZdS )é    )Úannotations)ÚTYPE_CHECKINGÚCallable)Ú	functions)Úparse_as_duration_string)Ú
deprecatedN)ÚIterable)Ú	timedelta)Ú	DataFrame)ÚClosedIntervalÚIntoExprÚLabelÚQuantileMethodÚ
SchemaDictÚStartBy)é   é   )ÚSelf)r   é   c                  óÖ   — e Zd ZdZd1d„Zd2d„Zd3d„Zd4d„Zd5d„Zd6d7d„Z	d6d7d„Z
d8d„Zd9d:d „Z ed!¦  «        d8d"„¦   «         Zd8d#„Zd8d$„Zd8d%„Zd8d&„Zd8d'„Zd8d(„Zd8d)„Z	 d;d<d/„Zd8d0„ZdS )=ÚGroupByzStarts a new GroupBy operation.Údfr   ÚbyúIntoExpr | Iterable[IntoExpr]Úmaintain_orderÚboolÚnamed_byr   ÚreturnÚNonec               ó>   — || _         || _        || _        || _        dS )aº  
        Utility class for performing a group by operation over the given DataFrame.

        Generated by calling `df.group_by(...)`.

        Parameters
        ----------
        df
            DataFrame to perform the group by operation over.
        *by
            Column or columns to group by. Accepts expression input. Strings are parsed
            as column names.
        maintain_order
            Ensure that the order of the groups is consistent with the input data.
            This is slower than a default group by.
        **named_by
            Additional column(s) to group by, specified as keyword arguments.
            The columns will be named as the keyword used.
        N)r   r   r   r   )Úselfr   r   r   r   s        úY/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/polars/dataframe/group_by.pyÚ__init__zGroupBy.__init__&   s'   € ð4 ˆŒØˆŒØ ˆŒØ,ˆÔÐÐó    r   c                ó¤  — ddl m} | j                             ¦   «         | _        d} | j                             ¦   «         j        | j        i | j        ¤d| j        i¤Ž 	                    t          j        ¦   «                              ¦   «                              |¦  «        ¦  «                             |                     ¦   «         ¬¦  «        }|                     t          j        ¦   «                              |¦  «        ¦  «                             ¦   «         | _        |                     |¦  «                             ¦   «         | _        d| _        | S )u3  
        Allows iteration over the groups of the group by operation.

        Each group is represented by a tuple of `(name, data)`. The group names are
        tuples of the distinct group values that identify each group.

        Examples
        --------
        >>> df = pl.DataFrame({"foo": ["a", "a", "b"], "bar": [1, 2, 3]})
        >>> for name, data in df.group_by("foo"):  # doctest: +SKIP
        ...     print(name)
        ...     print(data)
        (a,)
        shape: (2, 2)
        â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
        â”‚ foo â”† bar â”‚
        â”‚ --- â”† --- â”‚
        â”‚ str â”† i64 â”‚
        â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
        â”‚ a   â”† 1   â”‚
        â”‚ a   â”† 2   â”‚
        â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
        (b,)
        shape: (1, 2)
        â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
        â”‚ foo â”† bar â”‚
        â”‚ --- â”† --- â”‚
        â”‚ str â”† i64 â”‚
        â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
        â”‚ b   â”† 3   â”‚
        â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
        r   ©ÚQueryOptFlagsÚ__POLARS_GB_GROUP_INDICESr   ©Úoptimizations)Úpolars.lazyframe.opt_flagsr'   r   ÚrechunkÚlazyÚgroup_byr   r   r   ÚaggÚFÚfirstÚ
agg_groupsÚaliasÚcollectÚnoneÚselectÚallÚexcludeÚ	iter_rowsÚ_group_namesÚ	to_seriesÚ_group_indicesÚ_current_index©r!   r'   Útemp_colÚ	groups_dfs       r"   Ú__iter__zGroupBy.__iter__E   s(  € ðD 	=Ð<Ð<Ð<Ð<Ð<à”'—/’/Ñ#Ô#ˆŒØ.ˆðˆDŒGLŠL‰NŒNÜt”wðUØ"&¤-ðUð UØ@DÔ@SðUð Uð UçŠS•”‘”×%Ò%Ñ'Ô'×-Ò-¨hÑ7Ô7Ñ8Ô8ßŠW =×#5Ò#5Ñ#7Ô#7ˆWÑ8Ô8ð	 	ð &×,Ò,­Q¬U©W¬W¯_ª_¸XÑ-FÔ-FÑGÔG×QÒQÑSÔSˆÔØ'×.Ò.¨xÑ8Ô8×BÒBÑDÔDˆÔØˆÔàˆr$   ú$tuple[tuple[object, ...], DataFrame]c                óÜ   — | j         t          | j        ¦  «        k    rt          ‚t	          | j        ¦  «        }| j        | j        | j                  d d …f         }| xj         dz  c_         ||fS ©Né   ©r=   Úlenr<   ÚStopIterationÚnextr:   r   ©r!   Ú
group_nameÚ
group_datas      r"   Ú__next__zGroupBy.__next__x   óp   € ØÔ¥# dÔ&9Ñ":Ô":Ò:Ð:ÝÐå˜$Ô+Ñ,Ô,ˆ
Ø”W˜TÔ0°Ô1DÔEÀqÀqÀqÐHÔIˆ
ØÐÔ˜qÑ ÐÔà˜:Ð%Ð%r$   ÚaggsÚ
named_aggsc                óÞ   — ddl m}   | j                             ¦   «         j        | j        i | j        ¤d| j        i¤Žj        |i |¤Ž 	                    | 
                    ¦   «         ¬¦  «        S )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.

        >>> 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           â”‚
        â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        r   r&   r   r)   )r+   r'   r   r-   r.   r   r   r   r/   r4   r5   ©r!   rO   rP   r'   s       r"   r/   zGroupBy.agg‚   sœ   € ðR 	=Ð<Ð<Ð<Ð<Ð<ðð ˆDŒGLŠL‰NŒNÜt”wðUØ"&¤-ðUð UØ@DÔ@SðUð Uð Uä$ð&à$ð&ð &÷ ŠW =×#5Ò#5Ñ#7Ô#7ˆWÑ8Ô8ð		
r$   Úfunctionú Callable[[DataFrame], DataFrame]c                ó:  — | j         rd}t          |¦  «        ‚t          d„ | j        D ¦   «         ¦  «        sd}t          |¦  «        ‚| j        j                             | j        j                             t          | j        ¦  «        || j
        ¦  «        ¦  «        S )u1	  
        Apply a custom/user-defined function (UDF) over the groups as a sub-DataFrame.

        .. warning::
            This method is much slower than the native expressions API.
            Only use it if you cannot implement your logic otherwise.

        Implementing logic using a Python function is almost always *significantly*
        slower and more memory intensive than implementing the same logic using
        the native expression API because:

        - The native expression engine runs in Rust; UDFs run in Python.
        - Use of Python UDFs forces the DataFrame to be materialized in memory.
        - Polars-native expressions can be parallelised (UDFs cannot).
        - Polars-native expressions can be logically optimised (UDFs cannot).

        Wherever possible you should strongly prefer the native expression API
        to achieve the best performance.

        Parameters
        ----------
        function
            Custom function that receives a DataFrame and returns a DataFrame.

        Returns
        -------
        DataFrame

        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.group_by("color").map_groups(
        ...     lambda group_df: group_df.sample(2)
        ... )  # 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.filter(
        ...     pl.int_range(pl.len()).shuffle().over("color") < 2
        ... )  # doctest: +IGNORE_RESULT
        z;cannot call `map_groups` when grouping by named expressionsc              3  ó@   K  — | ]}t          |t          ¦  «        V — Œd S ©N)Ú
isinstanceÚstr)Ú.0Úcs     r"   ú	<genexpr>z%GroupBy.map_groups.<locals>.<genexpr>4  s,   è è € Ð7Ð7¨!•:˜a¥Ñ%Ô%Ð7Ð7Ð7Ð7Ð7Ð7r$   z7cannot call `map_groups` when grouping by an expression)r   Ú	TypeErrorr7   r   r   Ú	__class__Ú
_from_pydfÚ_dfÚgroup_by_map_groupsÚlistr   )r!   rS   Úmsgs      r"   Ú
map_groupszGroupBy.map_groupsô   s˜   € ðz Œ=ð 	!ØOˆCÝ˜C‘.”.Ð ÝÐ7Ð7¨t¬wÐ7Ñ7Ô7Ñ7Ô7ð 	!ØKˆCÝ˜C‘.”.Ð àŒwÔ ×+Ò+ØŒGŒK×+Ò+ÝT”W‘”˜x¨Ô)<ñô ñ
ô 
ð 	
r$   é   ÚnÚintc                óî   — ddl m}  | j                             ¦   «         j        | j        i | j        ¤d| j        i¤Ž                     |¦  «         	                    | 
                    ¦   «         ¬¦  «        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&   r   r)   )r+   r'   r   r-   r.   r   r   r   Úheadr4   r5   ©r!   rf   r'   s      r"   ri   zGroupBy.head>  ó‰   € ðZ 	=Ð<Ð<Ð<Ð<Ð<ðˆDŒGLŠL‰NŒNÜt”wðUØ"&¤-ðUð UØ@DÔ@SðUð Uð UçŠT!‰WŒWßŠW =×#5Ò#5Ñ#7Ô#7ˆWÑ8Ô8ð		
r$   c                óî   — ddl m}  | j                             ¦   «         j        | j        i | j        ¤d| j        i¤Ž                     |¦  «         	                    | 
                    ¦   «         ¬¦  «        S )um  
        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&   r   r)   )r+   r'   r   r-   r.   r   r   r   Útailr4   r5   rj   s      r"   rm   zGroupBy.tailt  rk   r$   c                óN   — |                       t          j        ¦   «         ¦  «        S )uj  
        Aggregate the groups into Series.

        Examples
        --------
        >>> df = pl.DataFrame({"a": ["one", "two", "one", "two"], "b": [1, 2, 3, 4]})
        >>> df.group_by("a", maintain_order=True).all()
        shape: (2, 2)
        â”Œâ”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
        â”‚ a   â”† b         â”‚
        â”‚ --- â”† ---       â”‚
        â”‚ str â”† list[i64] â”‚
        â•žâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•â•â•â•â•¡
        â”‚ one â”† [1, 3]    â”‚
        â”‚ two â”† [2, 4]    â”‚
        â””â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        )r/   r0   r7   ©r!   s    r"   r7   zGroupBy.allª  s   € ð$ xŠxœ™œÑ Ô Ð r$   NÚnameú
str | Nonec                ó€   — t          j        ¦   «         }||                     |¦  «        }|                      |¦  «        S )us  
        Return the number of rows in each group.

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

        Examples
        --------
        >>> df = pl.DataFrame({"a": ["Apple", "Apple", "Orange"], "b": [1, None, 2]})
        >>> df.group_by("a").len()  # doctest: +IGNORE_RESULT
        shape: (2, 2)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
        â”‚ a      â”† len â”‚
        â”‚ ---    â”† --- â”‚
        â”‚ str    â”† u32 â”‚
        â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•¡
        â”‚ Apple  â”† 2   â”‚
        â”‚ Orange â”† 1   â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
        >>> df.group_by("a").len(name="n")  # doctest: +IGNORE_RESULT
        shape: (2, 2)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
        â”‚ a      â”† n   â”‚
        â”‚ ---    â”† --- â”‚
        â”‚ str    â”† u32 â”‚
        â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•¡
        â”‚ Apple  â”† 2   â”‚
        â”‚ Orange â”† 1   â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
        )r0   rG   r3   r/   )r!   rp   Úlen_exprs      r"   rG   zGroupBy.len¾  s9   € õB ”5‘7”7ˆØÐØ—~’~ dÑ+Ô+ˆHØxŠx˜Ñ!Ô!Ð!r$   z6`GroupBy.count` was renamed; use `GroupBy.len` insteadc                ót   — |                       t          j        ¦   «                              d¦  «        ¦  «        S )uZ  
        Return the number of rows in each group.

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

        Rows containing null values count towards the total.

        Examples
        --------
        >>> df = pl.DataFrame(
        ...     {
        ...         "a": ["Apple", "Apple", "Orange"],
        ...         "b": [1, None, 2],
        ...     }
        ... )
        >>> df.group_by("a").count()  # doctest: +SKIP
        shape: (2, 2)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”€â”
        â”‚ a      â”† count â”‚
        â”‚ ---    â”† ---   â”‚
        â”‚ str    â”† u32   â”‚
        â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•â•â•¡
        â”‚ Apple  â”† 2     â”‚
        â”‚ Orange â”† 1     â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”€â”˜
        Úcount)r/   r0   rG   r3   ro   s    r"   ru   zGroupBy.countä  s(   € ð: xŠxœ™œŸš gÑ.Ô.Ñ/Ô/Ð/r$   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )uR  
        Aggregate the first values in the group.

        Examples
        --------
        >>> df = 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"],
        ...     }
        ... )
        >>> df.group_by("d", maintain_order=True).first()
        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/   r0   r7   r1   ro   s    r"   r1   zGroupBy.first  s$   € ð4 xŠxœ™œŸš™œÑ(Ô(Ð(r$   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )uP  
        Aggregate the last values in the group.

        Examples
        --------
        >>> df = 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"],
        ...     }
        ... )
        >>> df.group_by("d", maintain_order=True).last()
        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/   r0   r7   Úlastro   s    r"   rx   zGroupBy.last  ó$   € ð4 xŠxœ™œŸš™œÑ'Ô'Ð'r$   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )u@  
        Reduce the groups to the maximal value.

        Examples
        --------
        >>> df = 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"],
        ...     }
        ... )
        >>> df.group_by("d", maintain_order=True).max()
        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/   r0   r7   Úmaxro   s    r"   r{   zGroupBy.max;  ó$   € ð4 xŠxœ™œŸš™œÑ&Ô&Ð&r$   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )u·  
        Reduce the groups to the mean values.

        Examples
        --------
        >>> df = 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"],
        ...     }
        ... )
        >>> df.group_by("d", maintain_order=True).mean()
        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/   r0   r7   Úmeanro   s    r"   r~   zGroupBy.meanW  ry   r$   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )uZ  
        Return the median per group.

        Examples
        --------
        >>> df = 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"],
        ...     }
        ... )
        >>> df.group_by("d", maintain_order=True).median()
        shape: (2, 3)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”
        â”‚ d      â”† a   â”† b    â”‚
        â”‚ ---    â”† --- â”† ---  â”‚
        â”‚ str    â”† f64 â”† f64  â”‚
        â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡
        â”‚ Apple  â”† 2.0 â”† 4.0  â”‚
        â”‚ Banana â”† 4.0 â”† 13.0 â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
        )r/   r0   r7   Úmedianro   s    r"   r€   zGroupBy.medians  s&   € ð0 xŠxœ™œŸšÑ(Ô(Ñ)Ô)Ð)r$   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )uO  
        Reduce the groups to the minimal value.

        Examples
        --------
        >>> df = 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"],
        ...     }
        ... )
        >>> df.group_by("d", maintain_order=True).min()
        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/   r0   r7   Úminro   s    r"   r‚   zGroupBy.min  r|   r$   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )uV  
        Count the unique values per group.

        Examples
        --------
        >>> df = 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"],
        ...     }
        ... )
        >>> df.group_by("d", maintain_order=True).n_unique()
        shape: (2, 3)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”
        â”‚ d      â”† a   â”† b   â”‚
        â”‚ ---    â”† --- â”† --- â”‚
        â”‚ str    â”† u32 â”† u32 â”‚
        â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•¡
        â”‚ Apple  â”† 2   â”† 2   â”‚
        â”‚ Banana â”† 3   â”† 3   â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
        )r/   r0   r7   Ún_uniquero   s    r"   r„   zGroupBy.n_unique©  s(   € ð0 xŠxœ™œ×(Ò(Ñ*Ô*Ñ+Ô+Ð+r$   ÚnearestÚquantileÚfloatÚinterpolationr   c                óx   — |                       t          j        ¦   «                              ||¬¦  «        ¦  «        S )ui  
        Compute the quantile per group.

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

        Examples
        --------
        >>> df = 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"],
        ...     }
        ... )
        >>> df.group_by("d", maintain_order=True).quantile(1)
        shape: (3, 3)
        â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”¬â”€â”€â”€â”€â”€â”€â”
        â”‚ d      â”† a   â”† b    â”‚
        â”‚ ---    â”† --- â”† ---  â”‚
        â”‚ str    â”† f64 â”† f64  â”‚
        â•žâ•â•â•â•â•â•â•â•â•ªâ•â•â•â•â•â•ªâ•â•â•â•â•â•â•¡
        â”‚ Apple  â”† 3.0 â”† 10.0 â”‚
        â”‚ Orange â”† 2.0 â”† 0.5  â”‚
        â”‚ Banana â”† 5.0 â”† 14.0 â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
        )rˆ   )r/   r0   r7   r†   )r!   r†   rˆ   s      r"   r†   zGroupBy.quantileÃ  s0   € ðD xŠxœ™œ×(Ò(¨ÀÐ(ÑOÔOÑPÔPÐPr$   c                ór   — |                       t          j        ¦   «                              ¦   «         ¦  «        S )u'  
        Reduce the groups to the sum.

        Examples
        --------
        >>> df = 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"],
        ...     }
        ... )
        >>> df.group_by("d", maintain_order=True).sum()
        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/   r0   r7   Úsumro   s    r"   r‹   zGroupBy.sumç  r|   r$   )
r   r   r   r   r   r   r   r   r   r   ©r   r   ©r   rB   ©rO   r   rP   r   r   r   )rS   rT   r   r   )re   )rf   rg   r   r   )r   r   rW   )rp   rq   r   r   )r…   )r†   r‡   rˆ   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r#   rA   rM   r/   rd   ri   rm   r7   rG   r   ru   r1   rx   r{   r~   r€   r‚   r„   r†   r‹   © r$   r"   r   r   #   sÞ  € € € € € Ø)Ð)ð-ð -ð -ð -ð>1ð 1ð 1ð 1ðf&ð &ð &ð &ðp
ð p
ð p
ð p
ðdH
ð H
ð H
ð H
ðT4
ð 4
ð 4
ð 4
ð 4
ðl4
ð 4
ð 4
ð 4
ð 4
ðl!ð !ð !ð !ð($"ð $"ð $"ð $"ð $"ðL €ZÐHÑIÔIð0ð 0ð 0ñ JÔIð0ð<)ð )ð )ð )ð8(ð (ð (ð (ð8'ð 'ð 'ð 'ð8(ð (ð (ð (ð8*ð *ð *ð *ð4'ð 'ð 'ð 'ð8,ð ,ð ,ð ,ð6 @Ið"Qð "Qð "Qð "Qð "QðH'ð 'ð 'ð 'ð 'ð 'r$   r   c                  ó:   — e Zd ZdZdd„Zd d„Zd!d„Zd"d„Zd#d„ZdS )$ÚRollingGroupByz‰
    A rolling grouper.

    This has an `.agg` method which will allow you to run all polars expressions in a
    group by context.
    r   r   Úindex_columnr   Úperiodústr | timedeltaÚoffsetústr | timedelta | NoneÚclosedr   r.   ú$IntoExpr | Iterable[IntoExpr] | Noner   r   c               ó–   — t          |¦  «        }t          |¦  «        }|| _        || _        || _        || _        || _        || _        d S rW   )r   r   Útime_columnr—   r™   r›   r.   )r!   r   r–   r—   r™   r›   r.   s          r"   r#   zRollingGroupBy.__init__  sM   € õ *¨&Ñ1Ô1ˆÝ)¨&Ñ1Ô1ˆàˆŒØ'ˆÔØˆŒØˆŒØˆŒØ ˆŒˆˆr$   r   c                óŽ  — ddl m} d}| j                             ¦   «                              | j        | j        | j        | j        | j	        ¬¦  «         
                    t          j        ¦   «                              ¦   «                              |¦  «        ¦  «                             |                     ¦   «         ¬¦  «        }|                     t          j        ¦   «                              |¦  «        ¦  «                             ¦   «         | _        |                     |¦  «                             ¦   «         | _        d| _        | S )Nr   r&   r(   ©r–   r—   r™   r›   r.   r)   )r+   r'   r   r-   Úrollingrž   r—   r™   r›   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   s       r"   rA   zRollingGroupBy.__iter__   s  € Ø<Ð<Ð<Ð<Ð<Ð<à.ˆàŒGLŠL‰NŒNßŠWØ!Ô-Ø”{Ø”{Ø”{Øœð ñ ô ÷ ŠS•”‘”×%Ò%Ñ'Ô'×-Ò-¨hÑ7Ô7Ñ8Ô8ßŠW =×#5Ò#5Ñ#7Ô#7ˆWÑ8Ô8ð 	ð &×,Ò,­Q¬U©W¬W¯_ª_¸XÑ-FÔ-FÑGÔG×QÒQÑSÔSˆÔØ'×.Ò.¨xÑ8Ô8×BÒBÑDÔDˆÔØˆÔàˆr$   rB   c                óÜ   — | j         t          | j        ¦  «        k    rt          ‚t	          | j        ¦  «        }| j        | j        | j                  d d …f         }| xj         dz  c_         ||fS rD   rF   rJ   s      r"   rM   zRollingGroupBy.__next__7  rN   r$   rO   r   rP   c                ó  — ddl m}  | j                             ¦   «                              | j        | j        | j        | j        | j	        ¬¦  «        j
        |i |¤Ž                     |                     ¦   «         ¬¦  «        S )áë  
        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.
        r   r&   r    r)   )r+   r'   r   r-   r¡   rž   r—   r™   r›   r.   r/   r4   r5   rR   s       r"   r/   zRollingGroupBy.aggA  s’   € ð$ 	=Ð<Ð<Ð<Ð<Ð<ðˆDŒGLŠL‰NŒNßŠWØ!Ô-Ø”{Ø”{Ø”{Øœð ñ ô ô $ð&ð %ð&ð &÷ ŠW =×#5Ò#5Ñ#7Ô#7ˆWÑ8Ô8ð	
r$   rS   rT   ÚschemaúSchemaDict | Nonec                ó  — ddl m} | j                             ¦   «                              | j        | j        | j        | j        | j	        ¬¦  «         
                    ||¦  «                             |                     ¦   «         ¬¦  «        S )áö  
        Apply a custom/user-defined function (UDF) over the groups as a new DataFrame.

        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]).map_elements(lambda struct_series: ..)`

        Parameters
        ----------
        function
            Function to apply over each group of the `LazyFrame`; it receives
            a DataFrame and should return a DataFrame.
        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.
        r   r&   r    r)   )r+   r'   r   r-   r¡   rž   r—   r™   r›   r.   rd   r4   r5   ©r!   rS   r¥   r'   s       r"   rd   zRollingGroupBy.map_groupsb  s„   € ð: 	=Ð<Ð<Ð<Ð<Ð<ð ŒGLŠL‰NŒNßŠWØ!Ô-Ø”{Ø”{Ø”{Øœð ñ ô ÷ ŠZ˜ &Ñ)Ô)ßŠW =×#5Ò#5Ñ#7Ô#7ˆWÑ8Ô8ð	
r$   N)r   r   r–   r   r—   r˜   r™   rš   r›   r   r.   rœ   r   r   rŒ   r   rŽ   ©rS   rT   r¥   r¦   r   r   ©	r   r   r‘   r’   r#   rA   rM   r/   rd   r“   r$   r"   r•   r•     sƒ   € € € € € ðð ð!ð !ð !ð !ð(ð ð ð ð.&ð &ð &ð &ð
ð 
ð 
ð 
ðB*
ð *
ð *
ð *
ð *
ð *
r$   r•   c                  ó:   — e Zd ZdZd&d„Zd'd„Zd(d„Zd)d„Zd*d$„Zd%S )+ÚDynamicGroupByz…
    A dynamic grouper.

    This has an `.agg` method which allows you to run all polars expressions in a
    group by context.
    r   r   r–   r   Úeveryr˜   r—   rš   r™   Úinclude_boundariesr   r›   r   Úlabelr   r.   rœ   Ústart_byr   r   r   c               óì   — t          |¦  «        }t          |¦  «        }t          |¦  «        }|| _        || _        || _        || _        || _        || _        || _        || _        |	| _	        |
| _
        d S rW   )r   r   rž   r®   r—   r™   r°   r¯   r›   r.   r±   )r!   r   r–   r®   r—   r™   r¯   r›   r°   r.   r±   s              r"   r#   zDynamicGroupBy.__init__—  sw   € õ )¨Ñ/Ô/ˆÝ)¨&Ñ1Ô1ˆÝ)¨&Ñ1Ô1ˆàˆŒØ'ˆÔØˆŒ
ØˆŒØˆŒØˆŒ
Ø"4ˆÔØˆŒØ ˆŒØ ˆŒˆˆr$   r   c                ó¾  — ddl m} d}| j                             ¦   «                              | j        | j        | j        | j        | j	        | j
        | j        | j        | j        ¬¦	  «	                             t          j        ¦   «                              ¦   «                              |¦  «        ¦  «                             |                     ¦   «         ¬¦  «        }|                     t          j        ¦   «                              |¦  «        ¦  «                             ¦   «         | _        |                     |¦  «                             ¦   «         | _        d| _        | S )Nr   r&   r(   ©	r–   r®   r—   r™   r°   r¯   r›   r.   r±   r)   )r+   r'   r   r-   Úgroup_by_dynamicrž   r®   r—   r™   r°   r¯   r›   r.   r±   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   s       r"   rA   zDynamicGroupBy.__iter__´  s  € Ø<Ð<Ð<Ð<Ð<Ð<à.ˆàŒGLŠL‰NŒNßÒØ!Ô-Ø”jØ”{Ø”{Ø”jØ#'Ô#:Ø”{ØœØœð ñ 
ô 
÷ ŠS•”‘”×%Ò%Ñ'Ô'×-Ò-¨hÑ7Ô7Ñ8Ô8ßŠW =×#5Ò#5Ñ#7Ô#7ˆWÑ8Ô8ð 	ð" &×,Ò,­Q¬U©W¬W¯_ª_¸XÑ-FÔ-FÑGÔG×QÒQÑSÔSˆÔØ'×.Ò.¨xÑ8Ô8×BÒBÑDÔDˆÔØˆÔàˆr$   rB   c                óÜ   — | j         t          | j        ¦  «        k    rt          ‚t	          | j        ¦  «        }| j        | j        | j                  d d …f         }| xj         dz  c_         ||fS rD   rF   rJ   s      r"   rM   zDynamicGroupBy.__next__Ï  rN   r$   rO   r   rP   c                ó4  — ddl m}  | j                             ¦   «                              | j        | j        | j        | j        | j	        | j
        | j        | j        | j        ¬¦	  «	        j        |i |¤Ž                     |                     ¦   «         ¬¦  «        S )r¤   r   r&   r´   r)   )r+   r'   r   r-   rµ   rž   r®   r—   r™   r°   r¯   r›   r.   r±   r/   r4   r5   rR   s       r"   r/   zDynamicGroupBy.aggÙ  s¨   € ð$ 	=Ð<Ð<Ð<Ð<Ð<ðˆDŒGLŠL‰NŒNßÒØ!Ô-Ø”jØ”{Ø”{Ø”jØ#'Ô#:Ø”{ØœØœð ñ 
ô 
ô $ð&ð %ð&ð &÷ ŠW =×#5Ò#5Ñ#7Ô#7ˆWÑ8Ô8ð	
r$   rS   rT   r¥   r¦   c           
     ó:  — ddl m} | j                             ¦   «                              | j        | j        | j        | j        | j	        | j
        | j        | j        ¬¦  «                             ||¦  «                             |                     ¦   «         ¬¦  «        S )r¨   r   r&   )r–   r®   r—   r™   r¯   r›   r.   r±   r)   )r+   r'   r   r-   rµ   rž   r®   r—   r™   r¯   r›   r.   r±   rd   r4   r5   r©   s       r"   rd   zDynamicGroupBy.map_groupsþ  s•   € ð: 	=Ð<Ð<Ð<Ð<Ð<ð ŒGLŠL‰NŒNßÒØ!Ô-Ø”jØ”{Ø”{Ø#'Ô#:Ø”{ØœØœð ñ 	ô 	÷ ŠZ˜ &Ñ)Ô)ßŠW =×#5Ò#5Ñ#7Ô#7ˆWÑ8Ô8ð	
r$   N)r   r   r–   r   r®   r˜   r—   rš   r™   rš   r¯   r   r›   r   r°   r   r.   rœ   r±   r   r   r   rŒ   r   rŽ   rª   r«   r“   r$   r"   r­   r­     sƒ   € € € € € ðð ð!ð !ð !ð !ð:ð ð ð ð6&ð &ð &ð &ð#
ð #
ð #
ð #
ðJ-
ð -
ð -
ð -
ð -
ð -
r$   r­   ) Ú
__future__r   Útypingr   r   Úpolarsr   r0   Úpolars._utils.convertr   Úpolars._utils.deprecationr   ÚsysÚcollections.abcr	   Údatetimer
   r   Úpolars._typingr   r   r   r   r   r   Úversion_infor   Útyping_extensionsÚwarningsr   r•   r­   r“   r$   r"   ú<module>rÅ      s  ðØ "Ð "Ð "Ð "Ð "Ð "à *Ð *Ð *Ð *Ð *Ð *Ð *Ð *à !Ð !Ð !Ð !Ð !Ð !Ø :Ð :Ð :Ð :Ð :Ð :Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0àð 1Ø€J€J€JØ(Ð(Ð(Ð(Ð(Ð(Ø"Ð"Ð"Ð"Ð"Ð"à Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð Ô˜7Ò"Ð"ØÐÐÐÐÐÐà*Ð*Ð*Ð*Ð*Ð*à
Ô˜7Ò"Ð"Ø'Ð'Ð'Ð'Ð'Ð'Ð'à0Ð0Ð0Ð0Ð0Ð0ð^'ð ^'ð ^'ð ^'ð ^'ñ ^'ô ^'ð ^'ðBH
ð H
ð H
ð H
ð H
ñ H
ô H
ð H
ðV\
ð \
ð \
ð \
ð \
ñ \
ô \
ð \
ð \
ð \
r$   