Ë
    èË€h—  ã                  ó@  — 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r^d 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j2                  dk\  rd dlmZ nd dlmZ ej2                  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y)é    )Ú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	 	 	 	 	 	 	 	 	 	 dd„Zdd„Zdd„Z	 	 	 	 	 	 dd„Zdd„Zddd„Z	ddd„Z
dd	„Zdd d„Z ed«      dd„«       Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Z	 d!	 	 	 	 	 d"d„Zdd„Zy
)#ÚGroupByzStarts a new GroupBy operation.c               ó<   — || _         || _        || _        || _        y)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)ÚdfÚbyÚnamed_byÚmaintain_order)Úselfr   r   r   r   s        úu/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/polars/dataframe/group_by.pyÚ__init__zGroupBy.__init__&   s!   € ð4 ˆŒØˆŒØ ˆŒØ,ˆÕó    c                ó„  — ddl m} | j                  j                  «       | _        d} | j                  j	                  «       j
                  | j                  i | j                  ¤d| j                  i¤Žj                  t        j                  «       j                  «       j                  |«      «      j                  |j                  «       ¬«      }|j!                  t        j"                  «       j%                  |«      «      j'                  «       | _        |j!                  |«      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 	=à—'‘'—/‘/Ó#ˆŒØ.ˆðˆDG‰GL‰L‹Nß‰Xt—w‘wðUØ"&§-¡-ñUØ@D×@SÑ@SòUç‰S”—‘“×%Ñ%Ó'×-Ñ-¨hÓ7Ó8ß‰W =×#5Ñ#5Ó#7ˆWÓ8ð	 	ð &×,Ñ,¬Q¯U©U«W¯_©_¸XÓ-FÓG×QÑQÓSˆÔØ'×.Ñ.¨xÓ8×BÑBÓDˆÔØˆÔàˆr    c                ó  — | j                   t        | j                  «      k\  rt        ‚t	        | j
                  «      }| j                  | j                  | j                      d d …f   }| xj                   dz  c_         ||fS ©Né   ©r9   Úlenr8   ÚStopIterationÚnextr6   r   ©r   Ú
group_nameÚ
group_datas      r   Ú__next__zGroupBy.__next__x   óq   € Ø×Ñ¤# d×&9Ñ&9Ó":Ò:ÜÐä˜$×+Ñ+Ó,ˆ
Ø—W‘W˜T×0Ñ0°×1DÑ1DÑEÂqÐHÑIˆ
Ø×Ò˜qÑ Õà˜:Ð%Ð%r    c                ó  — ddl m}   | j                  j                  «       j                  | j
                  i | j                  ¤d| j                  i¤Žj                  |i |¤Žj                  |j                  «       ¬«      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+   r0   r1   ©r   ÚaggsÚ
named_aggsr#   s       r   r+   zGroupBy.agg‚   s{   € õR 	=ðð ˆDG‰GL‰L‹Nß‰Xt—w‘wðUØ"&§-¡-ñUØ@D×@SÑ@SòUç‰S$ð&à$ñ&÷ ‰W =×#5Ñ#5Ó#7ˆWÓ8ð		
r    c                óT  — | j                   rd}t        |«      ‚t        d„ | j                  D «       «      sd}t        |«      ‚| j                  j
                  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        «      –— Œ y ­w©N)Ú
isinstanceÚstr)Ú.0Úcs     r   ú	<genexpr>z%GroupBy.map_groups.<locals>.<genexpr>4  s   è ø€ Ò7¨!”:˜a¤×%Ñ7ùs   ‚z7cannot call `map_groups` when grouping by an expression)r   Ú	TypeErrorr3   r   r   Ú	__class__Ú
_from_pydfÚ_dfÚgroup_by_map_groupsÚlistr   )r   ÚfunctionÚmsgs      r   Ú
map_groupszGroupBy.map_groupsô   s„   € ðz =Š=ØOˆCÜ˜C“.Ð ÜÑ7¨t¯w©wÔ7Ô7ØKˆCÜ˜C“.Ð àw‰w× Ñ ×+Ñ+ØG‰GK‰K×+Ñ+ÜT—W‘W“˜x¨×)<Ñ)<óó
ð 	
r    c                ó   — ddl m}  | j                  j                  «       j                  | j
                  i | j                  ¤d| j                  i¤Žj                  |«      j                  |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"   r   r%   )r'   r#   r   r)   r*   r   r   r   Úheadr0   r1   ©r   Únr#   s      r   r`   zGroupBy.head>  ói   € õZ 	=ðˆDG‰GL‰L‹Nß‰Xt—w‘wðUØ"&§-¡-ñUØ@D×@SÑ@SòUç‰T!‹Wß‰W =×#5Ñ#5Ó#7ˆWÓ8ð		
r    c                ó   — ddl m}  | j                  j                  «       j                  | j
                  i | j                  ¤d| j                  i¤Žj                  |«      j                  |j                  «       ¬«      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   Útailr0   r1   ra   s      r   re   zGroupBy.tailt  rc   r    c                óH   — | j                  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+   r,   r3   ©r   s    r   r3   zGroupBy.allª  s   € ð$ x‰xœŸ™›Ó Ð r    Nc                ór   — t        j                  «       }||j                  |«      }| 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   â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”˜
        )r,   rB   r/   r+   )r   ÚnameÚlen_exprs      r   rB   zGroupBy.len¾  s3   € ôB —5‘5“7ˆØÐØ—~‘~ dÓ+ˆHØx‰x˜Ó!Ð!r    z6`GroupBy.count` was renamed; use `GroupBy.len` insteadc                óf   — | j                  t        j                  «       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+   r,   rB   r/   rg   s    r   rl   zGroupBy.countä  s"   € ð: x‰xœŸ™›Ÿ™ gÓ.Ó/Ð/r    c                ód   — | j                  t        j                  «       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+   r,   r3   r-   rg   s    r   r-   zGroupBy.first  s   € ð4 x‰xœŸ™›Ÿ™›Ó(Ð(r    c                ód   — | j                  t        j                  «       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+   r,   r3   Úlastrg   s    r   ro   zGroupBy.last  ó   € ð4 x‰xœŸ™›Ÿ™›Ó'Ð'r    c                ód   — | j                  t        j                  «       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+   r,   r3   Úmaxrg   s    r   rr   zGroupBy.max;  ó   € ð4 x‰xœŸ™›Ÿ™›Ó&Ð&r    c                ód   — | j                  t        j                  «       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+   r,   r3   Úmeanrg   s    r   ru   zGroupBy.meanW  rp   r    c                ód   — | j                  t        j                  «       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+   r,   r3   Úmedianrg   s    r   rw   zGroupBy.medians  s    € ð0 x‰xœŸ™›Ÿ™Ó(Ó)Ð)r    c                ód   — | j                  t        j                  «       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+   r,   r3   Úminrg   s    r   ry   zGroupBy.min  rs   r    c                ód   — | j                  t        j                  «       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+   r,   r3   Ún_uniquerg   s    r   r{   zGroupBy.n_unique©  s"   € ð0 x‰xœŸ™›×(Ñ(Ó*Ó+Ð+r    c                ój   — | j                  t        j                  «       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 â”‚
        â””â”€â”€â”€â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”€â”˜
        )Úinterpolation)r+   r,   r3   Úquantile)r   r~   r}   s      r   r~   zGroupBy.quantileÃ  s*   € ðD x‰xœŸ™›×(Ñ(¨ÀÐ(ÓOÓPÐPr    c                ód   — | j                  t        j                  «       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+   r,   r3   Úsumrg   s    r   r€   zGroupBy.sumç  rs   r    )
r   r   r   úIntoExpr | Iterable[IntoExpr]r   Úboolr   r   ÚreturnÚNone©rƒ   r   ©rƒ   z$tuple[tuple[object, ...], DataFrame]©rL   r   rM   r   rƒ   r   )r\   ú Callable[[DataFrame], DataFrame]rƒ   r   )é   )rb   Úintrƒ   r   )rƒ   r   rP   )ri   z
str | Nonerƒ   r   )Únearest)r~   Úfloatr}   r   rƒ   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r=   rH   r+   r^   r`   re   r3   rB   r   rl   r-   ro   rr   ru   rw   ry   r{   r~   r€   © r    r   r   r   #   sõ   „ Ù)ð-àð-ð +ð-ð ð	-ð
 ð-ð 
ó-ó>1óf&ðp
à,ðp
ð ðp
ð 
ó	p
ódH
ôT4
ôl4
ól!ô($"ñL ÐHÓIò0ó Jð0ó<)ó8(ó8'ó8(ó8*ó4'ó8,ð6 @Ið"QØð"QØ.<ð"Qà	ó"QôH'r    r   c                  ól   — e Zd ZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zd	d„Zd
d„Z	 	 	 	 	 	 dd„Z	 	 	 	 	 	 dd„Zy)ÚRollingGroupByz‰
    A rolling grouper.

    This has an `.agg` method which will allow you to run all polars expressions in a
    group by context.
    c               ó„   — t        |«      }t        |«      }|| _        || _        || _        || _        || _        || _        y rP   )r   r   Útime_columnÚperiodÚoffsetÚclosedr*   )r   r   Úindex_columnr–   r—   r˜   r*   s          r   r   zRollingGroupBy.__init__  sC   € ô *¨&Ó1ˆÜ)¨&Ó1ˆàˆŒØ'ˆÔØˆŒØˆŒØˆŒØ ˆr    c                ón  — ddl m} d}| j                  j                  «       j	                  | j
                  | j                  | j                  | j                  | j                  ¬«      j                  t        j                  «       j                  «       j                  |«      «      j                  |j!                  «       ¬«      }|j#                  t        j$                  «       j'                  |«      «      j)                  «       | _        |j#                  |«      j-                  «       | _        d| _        | S )Nr   r"   r$   ©r™   r–   r—   r˜   r*   r%   )r'   r#   r   r)   Úrollingr•   r–   r—   r˜   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   s       r   r=   zRollingGroupBy.__iter__   sá   € Ý<à.ˆàG‰GL‰L‹Nß‰WØ!×-Ñ-Ø—{‘{Ø—{‘{Ø—{‘{ØŸ™ð ó ÷ ‰S”—‘“×%Ñ%Ó'×-Ñ-¨hÓ7Ó8ß‰W =×#5Ñ#5Ó#7ˆWÓ8ð 	ð &×,Ñ,¬Q¯U©U«W¯_©_¸XÓ-FÓG×QÑQÓSˆÔØ'×.Ñ.¨xÓ8×BÑBÓDˆÔØˆÔàˆr    c                ó  — | j                   t        | j                  «      k\  rt        ‚t	        | j
                  «      }| j                  | j                  | j                      d d …f   }| xj                   dz  c_         ||fS r?   rA   rE   s      r   rH   zRollingGroupBy.__next__7  rI   r    c                ó*  — ddl m}  | j                  j                  «       j	                  | j
                  | j                  | j                  | j                  | j                  ¬«      j                  |i |¤Žj                  |j                  «       ¬«      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+   r0   r1   rK   s       r   r+   zRollingGroupBy.aggA  s€   € õ$ 	=ðˆDG‰GL‰L‹Nß‰WØ!×-Ñ-Ø—{‘{Ø—{‘{Ø—{‘{ØŸ™ð ó ÷ ‰S$ð&ð %ñ&÷ ‰W =×#5Ñ#5Ó#7ˆWÓ8ð	
r    c                ó*  — ddl m} | j                  j                  «       j	                  | j
                  | j                  | 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*   r^   r0   r1   ©r   r\   Úschemar#   s       r   r^   zRollingGroupBy.map_groupsb  sr   € õ: 	=ð G‰GL‰L‹Nß‰WØ!×-Ñ-Ø—{‘{Ø—{‘{Ø—{‘{ØŸ™ð ó ÷ ‰Z˜ &Ó)ß‰W =×#5Ñ#5Ó#7ˆWÓ8ð	
r    N)r   r   r™   r   r–   ústr | timedeltar—   ústr | timedelta | Noner˜   r   r*   ú$IntoExpr | Iterable[IntoExpr] | Nonerƒ   r„   r…   r†   r‡   ©r\   rˆ   r£   zSchemaDict | Nonerƒ   r   ©	r   rŽ   r   r   r   r=   rH   r+   r^   r‘   r    r   r“   r“     s   „ ñð!àð!ð ð!ð
  ð!ð 'ð!ð ð!ð 7ð!ð 
ó!ó(ó.&ð
à,ð
ð ð
ð 
ó	
ðB*
à2ð*
ð "ð*
ð 
ô	*
r    r“   c                  ó|   — e Zd ZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zd	d„Zd
d„Z	 	 	 	 	 	 dd„Z	 	 	 	 	 	 dd„Zy)ÚDynamicGroupByz…
    A dynamic grouper.

    This has an `.agg` method which allows you to run all polars expressions in a
    group by context.
    c               óÒ   — t        |«      }t        |«      }t        |«      }|| _        || _        || _        || _        || _        || _        || _        || _        |	| _	        |
| _
        y rP   )r   r   r•   Úeveryr–   r—   ÚlabelÚinclude_boundariesr˜   r*   Ústart_by)r   r   r™   r¬   r–   r—   r®   r˜   r­   r*   r¯   s              r   r   zDynamicGroupBy.__init__—  sj   € ô )¨Ó/ˆÜ)¨&Ó1ˆÜ)¨&Ó1ˆàˆŒØ'ˆÔØˆŒ
ØˆŒØˆŒØˆŒ
Ø"4ˆÔØˆŒØ ˆŒØ ˆr    c                óÆ  — ddl m} d}| j                  j                  «       j	                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  ¬«	      j                  t        j                   «       j#                  «       j%                  |«      «      j'                  |j)                  «       ¬«      }|j+                  t        j,                  «       j/                  |«      «      j1                  «       | _        |j+                  |«      j5                  «       | _        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+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   s       r   r=   zDynamicGroupBy.__iter__´  s   € Ý<à.ˆàG‰GL‰L‹NßÑØ!×-Ñ-Ø—j‘jØ—{‘{Ø—{‘{Ø—j‘jØ#'×#:Ñ#:Ø—{‘{ØŸ™ØŸ™ð ó 
÷ ‰S”—‘“×%Ñ%Ó'×-Ñ-¨hÓ7Ó8ß‰W =×#5Ñ#5Ó#7ˆWÓ8ð 	ð" &×,Ñ,¬Q¯U©U«W¯_©_¸XÓ-FÓG×QÑQÓSˆÔØ'×.Ñ.¨xÓ8×BÑBÓDˆÔØˆÔàˆr    c                ó  — | j                   t        | j                  «      k\  rt        ‚t	        | j
                  «      }| j                  | j                  | j                      d d …f   }| xj                   dz  c_         ||fS r?   rA   rE   s      r   rH   zDynamicGroupBy.__next__Ï  rI   r    c                ó‚  — ddl m}  | j                  j                  «       j	                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  ¬«	      j                  |i |¤Žj                  |j!                  «       ¬«      S )rŸ   r   r"   r±   r%   )r'   r#   r   r)   r²   r•   r¬   r–   r—   r­   r®   r˜   r*   r¯   r+   r0   r1   rK   s       r   r+   zDynamicGroupBy.aggÙ  sŸ   € õ$ 	=ðˆDG‰GL‰L‹NßÑØ!×-Ñ-Ø—j‘jØ—{‘{Ø—{‘{Ø—j‘jØ#'×#:Ñ#:Ø—{‘{ØŸ™ØŸ™ð ó 
÷ ‰S$ð&ð %ñ&÷ ‰W =×#5Ñ#5Ó#7ˆWÓ8ð	
r    c           
     ól  — ddl m} | j                  j                  «       j	                  | j
                  | j                  | 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¯   r^   r0   r1   r¢   s       r   r^   zDynamicGroupBy.map_groupsþ  sŠ   € õ: 	=ð G‰GL‰L‹NßÑØ!×-Ñ-Ø—j‘jØ—{‘{Ø—{‘{Ø#'×#:Ñ#:Ø—{‘{ØŸ™ØŸ™ð ó 	÷ ‰Z˜ &Ó)ß‰W =×#5Ñ#5Ó#7ˆWÓ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Å   „ ñð!àð!ð ð!ð
 ð!ð 'ð!ð 'ð!ð !ð!ð ð!ð ð!ð 7ð!ð ð!ð 
ó!ó:ó6&ð#
à,ð#
ð ð#
ð 
ó	#
ðJ-
à2ð-
ð "ð-
ð 
ô	-
r    rª   ) Ú
__future__r   Útypingr   r   Úpolarsr   r,   Ú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áÛÝ(Ý"å ÷÷ ð ×Ñ˜7Ò"Þå*à
×Ñ˜7Ò"Þ'å0÷^'ñ ^'÷BH
ñ H
÷V\
ò \
r    