
    WhE	                        d dl mZ d dlmZmZ d dlmZ er"d dlmZm	Z	 d dl
mZ d dlmZ d dlmZmZ d dlmZ  G d	 d
      Z G d d      Zy)    )annotations)TYPE_CHECKINGcast)is_sequence_of)IteratorSequence)GroupBy)LazyGroupBy)PolarsDataFramePolarsLazyFrame)
PolarsExprc                  \    e Zd ZU ded<   ded<   ed
d       Z	 	 	 	 	 	 	 	 ddZddZddZy	)PolarsGroupByr   _compliant_frameNativeGroupBy_groupedc                    | j                   S Nr   selfs    S/var/www/html/jupyter_env/lib/python3.12/site-packages/narwhals/_polars/group_by.py	compliantzPolarsGroupBy.compliant       $$$    c              0   t        |      | _        |r|j                  |      n|| _        t	        |t
              r+| j                  j                  j                  |      | _	        y | j                  j                  j                  d |D              | _	        y )Nc              3  4   K   | ]  }|j                     y wr   native.0args     r   	<genexpr>z)PolarsGroupBy.__init__.<locals>.<genexpr>&        /Ks

/K   
list_keys
drop_nullsr   r   strr   r   group_byr   r   dfkeysdrop_null_keyss       r   __init__zPolarsGroupBy.__init__   x     $Z
7Ed 32 dC( NN!!**40 	 &&///Kd/KK 	r   c                |    | j                   j                  d |D              }| j                  j                  |      S )Nc              3  4   K   | ]  }|j                     y wr   r   r    s     r   r#   z$PolarsGroupBy.agg.<locals>.<genexpr>*        &Bcszz&Br%   r   aggr   _with_nativer   aggs
agg_results      r   r6   zPolarsGroupBy.agg)   1    ]]&&&BT&BB
~~**:66r   c              #     K   | j                   D ]7  \  }}t        t        d|            | j                  j	                  |      f 9 y w)Nr*   )r   tupler   r   r7   )r   keyr-   s      r   __iter__zPolarsGroupBy.__iter__-   sE     }} 	KGCUC()4>>+F+Fr+JJJ	Ks   AA
N)returnr   )r-   r   r.   $Sequence[PolarsExpr] | Sequence[str]r/   boolr@   None)r9   r   r@   r   )r@   z1Iterator[tuple[tuple[str, ...], PolarsDataFrame]])	__name__
__module____qualname____annotations__propertyr   r0   r6   r?    r   r   r   r      sV    %%% %

 3
 
 

 7Kr   r   c                  T    e Zd ZU ded<   ded<   ed	d       Z	 	 	 	 	 	 	 	 d
dZddZy)PolarsLazyGroupByr   r   NativeLazyGroupByr   c                    | j                   S r   r   r   s    r   r   zPolarsLazyGroupBy.compliant6   r   r   c              0   t        |      | _        |r|j                  |      n|| _        t	        |t
              r+| j                  j                  j                  |      | _	        y | j                  j                  j                  d |D              | _	        y )Nc              3  4   K   | ]  }|j                     y wr   r   r    s     r   r#   z-PolarsLazyGroupBy.__init__.<locals>.<genexpr>G   r$   r%   r&   r,   s       r   r0   zPolarsLazyGroupBy.__init__:   r1   r   c                |    | j                   j                  d |D              }| j                  j                  |      S )Nc              3  4   K   | ]  }|j                     y wr   r   r    s     r   r#   z(PolarsLazyGroupBy.agg.<locals>.<genexpr>K   r4   r%   r5   r8   s      r   r6   zPolarsLazyGroupBy.aggJ   r;   r   N)r@   r   )r-   r   r.   rA   r/   rB   r@   rC   )r9   r   r@   r   )rD   rE   rF   rG   rH   r   r0   r6   rI   r   r   rK   rK   2   sP    %%% %

 3
 
 

 7r   rK   N)
__future__r   typingr   r   narwhals._utilsr   collections.abcr   r   polars.dataframe.group_byr	   r   polars.lazyframe.group_byr
   rL   narwhals._polars.dataframer   r   narwhals._polars.exprr   r   rK   rI   r   r   <module>rZ      s7    " & *2BJK0K KB7 7r   