
    ei_9              
         U d dl mZ d dlZd dlZd dlmZ d dlmZ d dlm	Z	m
Z
mZmZmZ d dlmZ d dlmZmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZmZ d dl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'm(Z( d dl)m*Z*m+Z+ e
Z,de-d<   	 ed    Z.de-d<   ed   Z/de-d<   ee.e/f   Z0de-d<   d Z1de-d<   dZ2de-d<    G d deeeeeef         Z3 G d deeef         Z4y)    )annotationsNreduce)chain)TYPE_CHECKINGAnyLiteralProtocoloverload)EagerNamespace)combine_alias_output_namescombine_evaluate_output_namesPandasLikeDataFramePandasLikeExpr)PandasSelectorNamespacePandasLikeSeries)NativeDataFrameTNativeSeriesT)is_non_nullable_boolean)
zip_strict)IterableSequence)	TypeAlias)ImplementationVersion)	IntoDTypeNonNestedLiteralr   
Incomplete	_Vertical   _HorizontalAxisVERTICAL
HORIZONTALc                      e Zd Zedd       Zedd       Zedd       Ze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ZddZddZedd       Zd dZ	 	 	 	 d!dZd dZ	 	 	 	 	 	 	 	 d"dZ	 d#	 	 	 	 	 	 	 d$dZy)%PandasLikeNamespacec                    t         S Nr   selfs    a/var/www/html/glpi_dashboard/venv/lib/python3.12/site-packages/narwhals/_pandas_like/namespace.py
_dataframezPandasLikeNamespace._dataframe4   s    ""    c                    t         S r+   r   r,   s    r.   _exprzPandasLikeNamespace._expr8   s    r0   c                    t         S r+   r   r,   s    r.   _serieszPandasLikeNamespace._series<   s    r0   c                ,    t        j                  |       S r+   )r   from_namespacer,   s    r.   	selectorszPandasLikeNamespace.selectors@   s    &55d;;r0   c                     || _         || _        y r+   )_implementation_version)r-   implementationversions      r.   __init__zPandasLikeNamespace.__init__D   s    -r0   c                f    dfd}| j                   j                  |t         t         |       S )Nc                8      fdD        }t        d |      gS )Nc              3  <   K   | ]  } |      D ]  }|   y wr+    ).0r2   sdfs      r.   	<genexpr>z=PandasLikeNamespace.coalesce.<locals>.func.<locals>.<genexpr>J   s!     >EE"I>qa>a>s   c                *    | j                  |d d       S )Nstrategylimit	fill_null)xys     r.   <lambda>z<PandasLikeNamespace.coalesce.<locals>.func.<locals>.<lambda>L   s    AKKDK$M r0   r   )rD   seriesexprss   ` r.   funcz*PandasLikeNamespace.coalesce.<locals>.funcI   s"    >U>FMvV r0   rQ   evaluate_output_namesalias_output_namescontextrD   r   returnzlist[PandasLikeSeries]r2   _from_callabler   r   r-   rP   rQ   s    ` r.   coalescezPandasLikeNamespace.coalesceH   s<    	 zz(("?"G95A	 ) 
 	
r0   c                j     d fdt        fdd d  j                   j                        S )Nc                    j                   j                  gd| j                  j                  dd       }r|j	                        S |S )Nliteralr   r#   )datanameindexrU   )r4   from_iterable_native_framera   cast)rD   pandas_seriesdtyper-   values     r.   _lit_pandas_seriesz3PandasLikeNamespace.lit.<locals>._lit_pandas_seriesW   sY     LL66W&&,,Qq1	 7 M $))%00  r0   c                     |       gS r+   rA   )rD   rh   s    r.   rN   z)PandasLikeNamespace.lit.<locals>.<lambda>c   s    *2./ r0   c                    dgS )Nr^   rA   _dfs    r.   rN   z)PandasLikeNamespace.lit.<locals>.<lambda>d   s    yk r0   rS   rT   r;   r<   )rD   r   rW   r   r   r9   r:   )r-   rg   rf   rh   s   ```@r.   litzPandasLikeNamespace.litV   s0    		! /"9#//MM
 	
r0   c                T     t         fdd d  j                   j                        S )Nc                n    j                   j                  t        | j                        gddg      gS )Nlenr   )r`   ra   rU   )r4   rb   rr   rc   )rD   r-   s    r.   rN   z)PandasLikeNamespace.len.<locals>.<lambda>l   s:    **))*+%sD +  r0   c                    dgS )Nrr   rA   rk   s    r.   rN   z)PandasLikeNamespace.len.<locals>.<lambda>q   s    ug r0   rm   rn   r,   s   `r.   rr   zPandasLikeNamespace.lenj   s-    
 #6#//MM

 
	
r0   c                f    dfd}| j                   j                  |t         t         |       S )Nc                     t        j                   fdD              }d |D        }t        t        j                  |      gS )Nc              3  .   K   | ]  } |        y wr+   rA   rB   exprrD   s     r.   rE   zCPandasLikeNamespace.sum_horizontal.<locals>.func.<locals>.<genexpr>z   s     $@$T"X$@   c              3  B   K   | ]  }|j                  d dd        yw)r   NrJ   rB   rC   s     r.   rE   zCPandasLikeNamespace.sum_horizontal.<locals>.func.<locals>.<genexpr>{   s     DAQ[[D$7D   )r   rb   r   operatoradd)rD   itnative_seriesrP   s   `  r.   rQ   z0PandasLikeNamespace.sum_horizontal.<locals>.funcy   s7    $$$@%$@@BDDM8<<788r0   rR   rV   rX   rZ   s    ` r.   sum_horizontalz"PandasLikeNamespace.sum_horizontalx   s<    	9
 zz(("?"G95A	 ) 
 	
r0   c               j    dfd}| j                   j                  |t         t         |       S )Nc                    D cg c]  } ||       D ]  }|  }}}st        d |D              rd}t        |      r	d |D        n
t        |      }t        t        j
                  |      gS c c}}w )Nc              3     K   | ]=  }|j                   j                  d k(  xr |j                         j                          ? ywobjectNnativerf   is_nullanyr{   s     r.   rE   zCPandasLikeNamespace.all_horizontal.<locals>.func.<locals>.<genexpr>   7      (EF(*@qyy{/@@(   AAzwCannot use `ignore_nulls=False` in `all_horizontal` for non-nullable NumPy-backed pandas Series when nulls are present.c              3  \   K   | ]$  }t        |      r|n|j                  d dd       & yw)TNr   rK   r{   s     r.   rE   zCPandasLikeNamespace.all_horizontal.<locals>.func.<locals>.<genexpr>   s4        13AT4QU9VV   *,)r   
ValueErroriterr   r}   and_rD   r2   rC   rO   msgr   rP   ignore_nullss         r.   rQ   z0PandasLikeNamespace.all_horizontal.<locals>.func   s    %*>EE"I>qa>a>F>C (JP( %
 P o%   $ &\  8=="-..# ?   A2rR   rV   rX   r-   r   rP   rQ   s    `` r.   all_horizontalz"PandasLikeNamespace.all_horizontal   s<    	/( zz(("?"G95A	 ) 
 	
r0   c               j    dfd}| j                   j                  |t         t         |       S )Nc                    D cg c]  } ||       D ]  }|  }}}st        d |D              rd}t        |      r	d |D        n
t        |      }t        t        j
                  |      gS c c}}w )Nc              3     K   | ]=  }|j                   j                  d k(  xr |j                         j                          ? ywr   r   r{   s     r.   rE   zCPandasLikeNamespace.any_horizontal.<locals>.func.<locals>.<genexpr>   r   r   zwCannot use `ignore_nulls=False` in `any_horizontal` for non-nullable NumPy-backed pandas Series when nulls are present.c              3  \   K   | ]$  }t        |      r|n|j                  d dd       & yw)FNr   r{   s     r.   rE   zCPandasLikeNamespace.any_horizontal.<locals>.func.<locals>.<genexpr>   s4        13AUDRV9WWr   )r   r   r   r   r}   or_r   s         r.   rQ   z0PandasLikeNamespace.any_horizontal.<locals>.func   s    %*>EE"I>qa>a>F>C (JP( %
 P o%   $ &\  8<<,--# ?r   rR   rV   rX   r   s    `` r.   any_horizontalz"PandasLikeNamespace.any_horizontal   s<    	.( zz(("?"G95A	 ) 
 	
r0   c                f    dfd}| j                   j                  |t         t         |       S )Nc                    D cg c]  } ||       D ]  }|  }}}d |D        }d |D        }t        t        j                  |      t        t        j                  |      z  gS c c}}w )Nc              3  D   K   | ]  }|j                  d dd        yw)r   NrG   rJ   r{   s     r.   rE   zDPandasLikeNamespace.mean_horizontal.<locals>.func.<locals>.<genexpr>   s     VAakk!d$k?Vs    c              3  B   K   | ]  }d |j                         z
    yw)r#   N)r   r{   s     r.   rE   zDPandasLikeNamespace.mean_horizontal.<locals>.func.<locals>.<genexpr>   s     <!a!))+o<r|   )r   r}   r~   )rD   r2   rC   expr_resultsrO   non_narP   s         r.   rQ   z1PandasLikeNamespace.mean_horizontal.<locals>.func   sd    +0D%%)DQADADLDVVF<|<F8<<06(,,3OOPP Es   A(rR   rV   rX   rZ   s    ` r.   mean_horizontalz#PandasLikeNamespace.mean_horizontal   s=    	Q zz(("?"G95A	 ) 
 	
r0   c                j     d fd} j                   j                  |t         t                S )Nc                6    t        t        j                   fdD                    }t        j	                  d |D        d      j
                  j                  d      j                  j                        j                  |d   j                        gS )	Nc              3  .   K   | ]  } |        y wr+   rA   rw   s     r.   rE   zCPandasLikeNamespace.min_horizontal.<locals>.func.<locals>.<genexpr>        -I4d2h-Iry   c              3  <   K   | ]  }|j                           y wr+   to_framer{   s     r.   rE   zCPandasLikeNamespace.min_horizontal.<locals>.func.<locals>.<genexpr>        6!6   
horizontalhowr#   axisr;   r<   r   )listr   rb   r   concatrc   minr9   r:   aliasr`   rD   rO   rP   r-   s   ` r.   rQ   z0PandasLikeNamespace.min_horizontal.<locals>.func   s~    %---I5-IIJF KK6v6L   #mCCQCK#'#7#7 MM %q	' r0   rR   rV   rX   rZ   s   `` r.   min_horizontalz"PandasLikeNamespace.min_horizontal   <    
	 zz(("?"G95A	 ) 
 	
r0   c                j     d fd} j                   j                  |t         t                S )Nc                6    t        t        j                   fdD                    }t        j	                  d |D        d      j
                  j                  d      j                  j                        j                  |d   j                        gS )	Nc              3  .   K   | ]  } |        y wr+   rA   rw   s     r.   rE   zCPandasLikeNamespace.max_horizontal.<locals>.func.<locals>.<genexpr>   r   ry   c              3  <   K   | ]  }|j                           y wr+   r   r{   s     r.   rE   zCPandasLikeNamespace.max_horizontal.<locals>.func.<locals>.<genexpr>   r   r   r   r   r#   r   r   r   )r   r   rb   r   r   r   maxr9   r:   r   r`   r   s   ` r.   rQ   z0PandasLikeNamespace.max_horizontal.<locals>.func   s~    %---I5-IIJF KK6v6L   fSSaS[#'#7#7 MM %q	' r0   rR   rV   rX   rZ   s   `` r.   max_horizontalz"PandasLikeNamespace.max_horizontal   r   r0   c                J    | j                   j                         j                  S )zvConcatenate pandas objects along a particular axis.

        Return the **native** equivalent of `pd.concat`.
        )r9   to_native_namespacer   r,   s    r.   _concatzPandasLikeNamespace._concat   s     ##779@@@r0   c                   | j                   j                         r'| j                  dk  r| j                  |t        d      S | j                  |t              S )N   Fr   copyr   )r9   	is_pandas_backend_versionr   r&   r-   dfss     r.   _concat_diagonalz$PandasLikeNamespace._concat_diagonal   sI    ))+0E0E0L<<(<??||Ch|//r0   c                  | j                   j                         rQt        j                         5  t        j                  ddt
               | j                  |t              cd d d        S | j                   j                         r'| j                  dk  r| j                  |t        d      S | j                  |t              S # 1 sw Y    xY w)NignorezDThe behavior of array concatenation with empty entries is deprecated)messagecategoryr   r   Fr   )
r9   is_cudfwarningscatch_warningsfilterwarningsFutureWarningr   r'   r   r   r   s     r.   _concat_horizontalz&PandasLikeNamespace._concat_horizontal  s     '')((* :''b*
 ||Cj|9: : !!++-$2G2G$2N<<*5<AA||Cj|11: :s   3CCc                  |d   j                   }t        |dd  d      D ]n  \  }}|j                   }t        |      t        |      k(  r||k(  j                         r=d|j	                          d| d|j	                          d}t        |       | j                  j                         r'| j                  dk  r| j                  |t        d	
      S | j                  |t              S )Nr   r#   )startz>unable to vstack, column names don't match:
   - dataframe 0: z
   - dataframe z: 
r   Fr   r   )columns	enumeraterr   allto_list	TypeErrorr9   r   r   r   r&   )r-   r   cols_0irD   cols_currentr   s          r.   _concat_verticalz$PandasLikeNamespace._concat_vertical  s    Qs12wa0 
	%EAr::L\"c&k18N7S7S7U))/)9(: ;&&'S<+?+?+A*B"F 
  n$
	% ))+0E0E0L<<(<??||Ch|//r0   c                   | j                   j                  j                         dfd}| j                  j	                  |t         t         |       S )Nc                   D cg c]  } ||       D ]  }|  }}}|D cg c]  }|j                         }}|D cg c]  }|j                          }}s=t        t        j                  |      }t        fd|      j                  | d       }|gS d t        ||      D        ^}}	|j                  |j                         j                  d|j                  j                  |j                  j                              fd|d d D        }
t        t        j                  d t        |
|	      D        |      }|gS c c}}w c c}w c c}w )Nc                    | z   |z   S r+   rA   )rL   rM   	separators     r.   rN   z>PandasLikeNamespace.concat_str.<locals>.func.<locals>.<lambda>0  s    Q]Q-> r0   c              3  H   K   | ]  \  }}|j                  | d         yw Nzip_with)rB   rC   nms      r.   rE   z?PandasLikeNamespace.concat_str.<locals>.func.<locals>.<genexpr>7  s&      ',1ArAJJsB''s    "sep)r`   ra   rf   c              3  D   K   | ]  }j                  | d         ywr   r   )rB   r   	sep_arrays     r.   rE   z?PandasLikeNamespace.concat_str.<locals>.func.<locals>.<genexpr>B  s      Sbi00"b9Ss    c              3  ,   K   | ]  \  }}||z     y wr+   rA   )rB   rC   vs      r.   rE   z?PandasLikeNamespace.concat_str.<locals>.func.<locals>.<genexpr>E  s     Ftq!QUFs   )rd   r   r   r}   r   r   r   _with_native__native_namespace__Seriesr   ra   rf   r~   )rD   r2   rC   r   rO   	null_masknull_mask_resultresult
init_valuevalues
separatorsr   rP   r   r   strings              @r.   rQ   z,PandasLikeNamespace.concat_str.<locals>.func)  sO   +0D%%)DQADADLD.:;affVn;F;.:;;I;#)(,,	#B  >GPP%%t2 8O%'5?	5R'#
V '33335<<!"(//55(//55	 = 	 TIcrNS
LLFz*f'EF 8O? E;;s   EEErR   rV   )r:   dtypesStringr2   rY   r   r   )r-   r   r   rP   rQ   r   s    ``` @r.   
concat_strzPandasLikeNamespace.concat_str$  s\     %%,,. 	  	D zz(("?"G95A	 ) 
 	
r0   Nc                @    |j                   }| ||      S  |||      S r+   )where)r-   whenthen	otherwiser  s        r.   _if_then_elsez!PandasLikeNamespace._if_then_elseR  s(     !JJ'/uT{KU45KKr0   )rW   ztype[PandasLikeDataFrame])rW   ztype[PandasLikeExpr])rW   ztype[PandasLikeSeries])rW   r   )r;   r   r<   r   rW   None)rP   r   rW   r   )rg   r    rf   zIntoDType | NonerW   r   )rW   r   )rP   r   r   boolrW   r   )rW   z._NativeConcat[NativeDataFrameT, NativeSeriesT])r   zSequence[NativeDataFrameT]rW   r   )r   z*Sequence[NativeDataFrameT | NativeSeriesT]rW   r   )rP   r   r   strr   r	  rW   r   r+   )r  r   r  r   r  zNativeSeriesT | NonerW   r   )__name__
__module____qualname__propertyr/   r2   r4   r7   r=   r[   ro   rr   r   r   r   r   r   r   r   r   r   r   r  r  rA   r0   r.   r)   r)   +   sD    # #       < < 

(


$
48
	
<
$
48
	
<

(
( A A0
2=2	20",
$,
14,
DH,
	,
d +/	LL L (	L
 
Lr0   r)   c                      e Zd Zedd	 	 	 	 	 	 	 d	d       Zedd	 	 	 	 	 	 	 d
d       Zedd	 	 	 	 	 	 	 dd       Zedd	 	 	 	 	 	 	 dd       Zdd	 	 	 	 	 	 	 ddZy)_NativeConcat.)r   c                    y r+   rA   r-   objsr   r   s       r.   __call__z_NativeConcat.__call__]       r0   c                    y r+   rA   r  s       r.   r  z_NativeConcat.__call__e  s     r0   c                    y r+   rA   r  s       r.   r  z_NativeConcat.__call__i  r  r0   c                    y r+   rA   r  s       r.   r  z_NativeConcat.__call__q  s     ,/r0   Nc                    y r+   rA   r  s       r.   r  z_NativeConcat.__call__z  s     ,/r0   )r  zIterable[NativeDataFrameT]r   r"   r   bool | NonerW   r   )r  zIterable[NativeSeriesT]r   r"   r   r  rW   r   )r  *Iterable[NativeDataFrameT | NativeSeriesT]r   r$   r   r  rW   r   )r  r  r   r%   r   r  rW   z NativeDataFrameT | NativeSeriesT)r  r  r  r   r  rA   r0   r.   r  r  \  s$     ( 	
  
  UX+6?GR	    8 	
  
    /8/ 	/
 / 
*/ / !/8/ 	/
 / 
*/r0   r  )5
__future__r   r}   r   	functoolsr   	itertoolsr   typingr   r   r	   r
   r   narwhals._compliantr   narwhals._expression_parsingr   r   narwhals._pandas_like.dataframer   narwhals._pandas_like.exprr   narwhals._pandas_like.selectorsr   narwhals._pandas_like.seriesr   narwhals._pandas_like.typingr   r   narwhals._pandas_like.utilsr   narwhals._utilsr   collections.abcr   r   typing_extensionsr   r   r   narwhals.typingr   r    r!   __annotations__r"   r$   r%   r&   r'   r)   r  rA   r0   r.   <module>r-     s    "     B B . @ 5 C 9 H ? &2+7; 
I  > qz	9 ! Y #)[01i 1) 
K nL		nLb	$/H-}<= $/r0   