
    hhE	                        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dS )    )annotations)TYPE_CHECKINGcast)is_sequence_of)IteratorSequence)GroupBy)LazyGroupBy)PolarsDataFramePolarsLazyFrame)
PolarsExprc                  T    e Zd ZU ded<   ded<   edd            ZddZddZddZdS )PolarsGroupByr   _compliant_frameNativeGroupBy_groupedreturnc                    | j         S Nr   selfs    P/var/www/histauto/venv/lib/python3.11/site-packages/narwhals/_polars/group_by.py	compliantzPolarsGroupBy.compliant       $$    dfkeys$Sequence[PolarsExpr] | Sequence[str]drop_null_keysboolNonec              .   t          |          | _        |r|                    |          n|| _        t	          |t
                    r| j        j                            |          n(| j        j                            d |D                       | _	        d S )Nc              3  $   K   | ]}|j         V  d S r   native.0args     r   	<genexpr>z)PolarsGroupBy.__init__.<locals>.<genexpr>&   $      /K/Ks
/K/K/K/K/K/Kr   
list_keys
drop_nullsr   r   strr   r&   group_byr   r   r   r   r    s       r   __init__zPolarsGroupBy.__init__        $ZZ
7E Md 3 3 32 dC((LDN!**4000&///K/Kd/K/K/KKK 	r   aggsr   c                ~    | j                             d |D                       }| j                            |          S )Nc              3  $   K   | ]}|j         V  d S r   r%   r'   s     r   r*   z$PolarsGroupBy.agg.<locals>.<genexpr>*   $      &B&Bcsz&B&B&B&B&B&Br   r   aggr   _with_nativer   r5   
agg_results      r   r:   zPolarsGroupBy.agg)   <    ]&&&B&BT&B&B&BBB
~**:666r   1Iterator[tuple[tuple[str, ...], PolarsDataFrame]]c              #     K   | j         D ]>\  }}t          t          d|                    | j                            |          fV  ?d S )Nr0   )r   tupler   r   r;   )r   keyr   s      r   __iter__zPolarsGroupBy.__iter__-   s_      } 	K 	KGCUC(())4>+F+Fr+J+JJJJJJ	K 	Kr   N)r   r   )r   r   r   r   r    r!   r   r"   )r5   r   r   r   )r   r?   )	__name__
__module____qualname____annotations__propertyr   r3   r:   rC    r   r   r   r      s         %%%%% % % X%
 
 
 
 7 7 7 7K K K K K Kr   r   c                  L    e Zd ZU ded<   ded<   edd            ZddZddZdS )PolarsLazyGroupByr   r   NativeLazyGroupByr   r   c                    | j         S r   r   r   s    r   r   zPolarsLazyGroupBy.compliant6   r   r   r   r   r   r    r!   r"   c              .   t          |          | _        |r|                    |          n|| _        t	          |t
                    r| j        j                            |          n(| j        j                            d |D                       | _	        d S )Nc              3  $   K   | ]}|j         V  d S r   r%   r'   s     r   r*   z-PolarsLazyGroupBy.__init__.<locals>.<genexpr>G   r+   r   r,   r2   s       r   r3   zPolarsLazyGroupBy.__init__:   r4   r   r5   r   c                ~    | j                             d |D                       }| j                            |          S )Nc              3  $   K   | ]}|j         V  d S r   r%   r'   s     r   r*   z(PolarsLazyGroupBy.agg.<locals>.<genexpr>K   r8   r   r9   r<   s      r   r:   zPolarsLazyGroupBy.aggJ   r>   r   N)r   r   )r   r   r   r   r    r!   r   r"   )r5   r   r   r   )rD   rE   rF   rG   rH   r   r3   r:   rI   r   r   rK   rK   2   st         %%%%% % % X%
 
 
 
 7 7 7 7 7 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      s   " " " " " " & & & & & & & & * * * * * * 122222222BBBBBBJJJJJJKKKKKKKK000000K K K K K K K KB7 7 7 7 7 7 7 7 7 7r   