
    Wh                        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
 d dlZ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mZmZmZmZmZmZmZmZm Z m!Z! d d	l"m#Z$m%Z& d d
l'm(Z( d dl)m*Z+ d dl,m-Z-m.Z.m/Z/ d dl0m1Z2 d dl3m4Z5 d dl6m7Z7m8Z8m9Z9 d dl:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZV d dlWmXZXmYZY d dlZm[Z[m\Z\m]Z] erd dl^m_Z_m`Z`maZa d dlbmcZc d dldmeZemfZf d dlgmhZh d dlimjZjmkZkmlZlmmZmmnZnmoZompZp d dl"mqZqmrZr d dlsmtZt d dlumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~mZ  edd      Z edd      Z ed d!      Z ed"e#      Z eed$      Z ed%      Z ed&d'e(      Z G d) d*e$eX         Z# G d+ d,e&eY         Z% G d- d.e5e         Z4 G d/ d0e+      Z* G d1 d2e2      Z1e
dd3       Ze
dd4       Ze
dd5       Ze
dd6       Z	 	 	 	 dd7Ze
dd8       Ze
dd9       Ze
dd:       Ze
	 	 	 	 	 	 dd;       Ze
d<d<d=	 	 	 	 	 	 	 	 	 	 	 	 	 dd>       Ze
d<d<d?	 	 	 	 	 	 	 	 	 	 	 	 	 dd@       Ze
d<d<d<dA	 	 	 	 	 	 	 	 	 	 	 	 	 ddB       Ze
d<d<d<dA	 	 	 	 	 	 	 	 	 	 	 	 	 ddC       Ze
d<d<d<dD	 	 	 	 	 	 	 	 	 	 	 	 	 ddE       Ze
d<d<d<dD	 	 	 	 	 	 	 	 	 	 	 	 	 ddF       Ze
d<d<d<dG	 	 	 	 	 	 	 	 	 	 	 	 	 ddH       Ze
d<d<d<dI	 	 	 	 	 	 	 	 	 	 	 	 	 ddJ       Ze
d<d<d<d<dK	 	 	 	 	 	 	 	 	 	 	 	 	 ddL       Ze
d<d<d<d<dK	 	 	 	 	 	 	 	 	 	 	 	 	 ddM       Ze
d<d<d<d<dK	 	 	 	 	 	 	 	 	 	 	 	 	 ddN       Ze
d<d<d<d<dO	 	 	 	 	 	 	 	 	 	 	 	 	 ddP       Ze
d<d<d<d<d<dQ	 	 	 	 	 	 	 	 	 	 	 	 	 ddR       Ze
d<d<d<d<dS	 	 	 	 	 	 	 	 	 	 	 	 	 ddT       Ze
d<d<d<d<dU	 	 	 	 	 	 	 	 	 	 	 	 	 ddV       Ze
d<d<d<d<dW	 	 	 	 	 	 	 	 	 	 	 	 	 ddX       Ze
d<d<d<d<d<dQ	 	 	 	 	 	 	 	 	 	 	 	 	 ddY       Ze
d<d<d=	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ       Ze
d<d<d?	 	 	 	 	 	 	 	 	 	 	 	 	 dd[       Ze
d<d<d<dA	 	 	 	 	 	 	 	 	 	 	 	 	 dd\       Ze
d<d<d<dA	 	 	 	 	 	 	 	 	 	 	 	 	 dd]       Ze
d<d<d<dD	 	 	 	 	 	 	 	 	 	 	 	 	 dd^       Ze
d<d<d<dD	 	 	 	 	 	 	 	 	 	 	 	 	 dd_       Ze
d<d<d<dG	 	 	 	 	 	 	 	 	 	 	 	 	 dd`       Ze
d<d<d<dI	 	 	 	 	 	 	 	 	 	 	 	 	 dda       Ze
d<d<d<d<dK	 	 	 	 	 	 	 	 	 	 	 	 	 ddb       Ze
d<d<d<d<dK	 	 	 	 	 	 	 	 	 	 	 	 	 ddc       Ze
d<d<d<d<dd	 	 	 	 	 	 	 	 	 	 	 	 	 dde       Ze
d<d<d<d<df	 	 	 	 	 	 	 	 	 	 	 	 	 ddg       Ze
d<d<d<d<dh	 	 	 	 	 	 	 	 	 	 	 	 	 ddi       Ze
d<d<d<d<dj	 	 	 	 	 	 	 	 	 	 	 	 	 ddk       Ze
d<d<d<d<d<dl	 	 	 	 	 	 	 	 	 	 	 	 	 ddm       Ze
d<d<d<d<d<dl	 	 	 	 	 	 	 	 	 	 	 	 	 ddn       Ze
dodp	 	 	 	 	 	 	 	 	 	 	 	 	 ddq       Zdddodododdr	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddsZe
d<dt	 	 	 	 	 ddu       Ze
d<dt	 	 	 	 	 ddv       Ze
d<dt	 	 	 	 	 ddw       Ze
ddx       Ze
d<dy	 	 	 	 	 ddz       Ze
d<dy	 	 	 	 	 dd{       Ze
d<dy	 	 	 	 	 dd|       Ze
dd}       Zddd~	 	 	 	 	 	 	 ddZ	 ddddodododdr	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZddZddZddZddZdddZddZddZddZddZddZddZdod	 	 	 	 	 ddZdod	 	 	 	 	 ddZddZddZddZddod	 	 	 	 	 	 	 	 	 ddZddZ	 	 	 	 ddZ G d dej>                        Z G d dej@                  e*      ZddZ ed      	 dddd	 	 	 	 	 	 	 	 	 	 	 dd       Z ed      ddd	 	 	 	 	 	 	 dd       Z e       	 dddd	 	 	 	 	 	 	 	 	 dd       Z ed      	 dddd	 	 	 	 	 	 	 	 	 dd       Z ed      ddd	 	 	 	 	 	 	 	 	 dd       Z ed      ddd	 	 	 	 	 	 	 	 	 dd       Z ed      ddd	 	 	 	 	 	 	 	 	 dd       Z ed      ddd	 	 	 	 	 	 	 	 	 dd       Zg dZy)    )annotationswraps)TYPE_CHECKINGAnyCallableLiteralcastoverloadN)
exceptions	functions)issue_warning)TypeVarassert_never)ImplementationVersiondeprecate_native_namespacegenerate_temporary_column_nameinherit_docis_ordered_categoricalmaybe_align_indexmaybe_convert_dtypesmaybe_get_indexmaybe_reset_indexmaybe_set_indexvalidate_strict_and_pass_though)	DataFrame	LazyFrame)InvalidIntoExprErrorExpr)_new_series_implconcatshow_versions)SchemaSeries)dependenciesdtypes	selectors)ArrayBinaryBooleanCategoricalDateDatetimeDecimalDurationEnumFieldFloat32Float64Int8Int16Int32Int64Int128ListObjectStringStructTimeUInt8UInt16UInt32UInt64UInt128Unknown)IntoDataFrameTIntoLazyFrameT)_from_native_implget_native_namespaceto_py_scalar)IterableMappingSequence)
ModuleType)	ParamSpecSelf)IntoArrowTable)ArrowBackendEagerAllowedIntoBackendLazyAllowedPandasPolars)MultiColSelectorMultiIndexSelector)DType)

FileSource	IntoDTypeIntoExpr	IntoFrame
IntoSeriesNonNestedLiteralSingleColSelectorSingleIndexSelector_1DArray_2DArray
DataFrameTDataFrame[Any])bound
LazyFrameTLazyFrame[Any]SeriesTSeries[Any]T)defaultPRIntoSeriesTra   )ri   ro   c                      e Zd Zej                  Z ee      d fd       Ze		 	 	 	 	 	 d fd       Z
e		 ddd	 	 	 	 	 	 	 d fd       Ze		 d	 	 	 	 	 	 	 d fd       Zedd       Zed d       Zed!d	       Ze	 	 	 	 d"d
       Ze	 	 	 	 d#d       Z	 	 	 	 d$ fdZd% fdZ	 ddd	 	 	 	 	 d& fdZeddd'd       Zed(d       Zedd	 	 	 d)d       Zdd	 	 	 d) fdZd* fdZd* fdZd+dZ xZS ),r   c               d    |j                   t        j                  u sJ t        |   ||       y N)level_versionr   V1super__init__selfdfrv   	__class__s      U/var/www/html/jupyter_env/lib/python3.12/site-packages/narwhals/stable/v1/__init__.pyr{   zDataFrame.__init__m   +    {{gjj(((5)    c               >    t         |   ||      }t        d|      S Nbackendrh   )rz   
from_arrowr
   )clsnative_framer   resultr   s       r   r   zDataFrame.from_arrowu   s'     #L'#B$f--r   Nr   c               @    t         |   |||      }t        d|      S r   )rz   	from_dictr
   r   dataschemar   r   r   s        r   r   zDataFrame.from_dict|   s)     "4"A$f--r   c               @    t         |   |||      }t        d|      S r   rz   
from_numpyr
   r   s        r   r   zDataFrame.from_numpy   s)     #D&'#B$f--r   c                "    t        dt              S )Ntype[Series[Any]])r
   r'   r}   s    r   _serieszDataFrame._series   s    '00r   c                "    t        dt              S )Ntype[LazyFrame[Any]])r
   r   r   s    r   
_lazyframezDataFrame._lazyframe   s    *I66r   c                     y N r}   items     r   __getitem__zDataFrame.__getitem__   s    WZr   c                     y r   r   r   s     r   r   zDataFrame.__getitem__   s     r   c                     y r   r   r   s     r   r   zDataFrame.__getitem__   s     r   c                "    t         |   |      S r   )rz   r   )r}   r   r   s     r   r   zDataFrame.__getitem__   s     w"4((r   c                "    t         |   |      S r   )rz   
get_column)r}   namer   s     r   r   zDataFrame.get_column   s     w!$''r   )sessionc               8    t        t        | 	  ||            S )N)r   r   )
_stableifyrz   lazy)r}   r   r   r   s      r   r   zDataFrame.lazy   s     %',w,HIIr   .	as_seriesc                    y r   r   r}   r   s     r   to_dictzDataFrame.to_dict   s    TWr   c                    y r   r   r   s     r   r   zDataFrame.to_dict   s    MPr   Tc                    y r   r   r   s     r   r   zDataFrame.to_dict   s     9<r   c               $    t         |   |      S )Nr   )rz   r   )r}   r   r   s     r   r   zDataFrame.to_dict   s    
 w33r   c                2    t        t        | 	               S r   )r   rz   is_duplicatedr}   r   s    r   r   zDataFrame.is_duplicated   s    %'/122r   c                2    t        t        | 	               S r   )r   rz   	is_uniquer   s    r   r   zDataFrame.is_unique   s    %'+-..r   c                P    | j                  t               j                               S r   selectall_l1_normr   s    r   r   zDataFrame._l1_norm       {{35>>+,,r   r~   r   rv   &Literal['full', 'lazy', 'interchange']returnNone)r   rR   r   IntoBackend[EagerAllowed]r   rh   r   )r   Mapping[str, Any]r   #Mapping[str, DType] | Schema | Noner    IntoBackend[EagerAllowed] | Noner   rh   )r   rf   r   3Mapping[str, DType] | Schema | Sequence[str] | Noner   r   r   rh   )r   r   )r   r   )r   z-tuple[SingleIndexSelector, SingleColSelector]r   r   )r   z2str | tuple[MultiIndexSelector, SingleColSelector]r   rm   )r   zSingleIndexSelector | MultiIndexSelector | MultiColSelector | tuple[SingleIndexSelector, MultiColSelector] | tuple[MultiIndexSelector, MultiColSelector]r   rQ   )r   a  SingleIndexSelector | SingleColSelector | MultiColSelector | MultiIndexSelector | tuple[SingleIndexSelector, SingleColSelector] | tuple[SingleIndexSelector, MultiColSelector] | tuple[MultiIndexSelector, SingleColSelector] | tuple[MultiIndexSelector, MultiColSelector]r   zSeries[Any] | Self | Any)r   strr   r'   )r   zIntoBackend[LazyAllowed] | Noner   z
Any | Noner   rk   )r   Literal[True]r   zdict[str, Series[Any]])r   Literal[False]r   zdict[str, list[Any]])r   boolr   z-dict[str, Series[Any]] | dict[str, list[Any]])r   rm   r   rQ   )__name__
__module____qualname__r   ry   rx   r   NwDataFramer{   classmethodr   r   r   propertyr   r   r   r   r   r   r   r   r   r   __classcell__r   s   @r   r   r   j   s   zzH* * .).7P.	. .  7;.
 59.. 4.
 2. 
. .  GK.. D.
 +. 
. . 1 1 7 7 Z ZF	  	:	 
	 	):) 
")( 48J #	J0J 	J
 
J 47W WP P#'< <	6< < $(4 4	643/-r   r   c                       e Zd Z ee      d fd       Zedd       ZddZ	 d	 	 	 	 	 d fdZ	ddZ
dd fdZdddZ	 ddd		 	 	 	 	 dd
Z xZS )r   c               d    |j                   t        j                  u sJ t        |   ||       y ru   rw   r|   s      r   r{   zLazyFrame.__init__   r   r   c                    t         S r   r   r   s    r   
_dataframezLazyFrame._dataframe       r   c                    ddl m} ddlm} t	        ||      rd}t        |      t	        ||t        f      r!| j                         j                  |d      S t        j                  t        |            )Nr   r    r&   z.Mixing Series with LazyFrame is not supported.F)
str_as_lit)narwhals.exprr!   narwhals.seriesr'   
isinstance	TypeErrorr   __narwhals_namespace__parse_into_exprr   from_invalid_typetype)r}   argr!   r'   msgs        r   _extract_compliantzLazyFrame._extract_compliant   sf     	'*c6"BCC. cD#;'..0@@QV@WW"44T#Y??r   Nc                8    t        t        |   dd|i|      S )Nr   r   )r   rz   collect)r}   r   kwargsr   s      r   r   zLazyFrame.collect   s!     %'/D'DVDEEr   c                P    | j                  t               j                               S r   r   r   s    r   r   zLazyFrame._l1_norm   r   r   c                "    t         |   |      S )Get the last `n` rows.)rz   tail)r}   nr   s     r   r   zLazyFrame.tail  s    w|Ar   c                Z    | j                  | j                  j                  ||            S )zTake every nth row in the DataFrame and return as a new DataFrame.

        Arguments:
            n: Gather every *n*-th row.
            offset: Starting index.
        r   offset)_with_compliant_compliant_framegather_everyr}   r   r   s      r   r   zLazyFrame.gather_every  s0     ##!!..6.B
 	
r   )order_byc                   t        |t              r|gn|}| j                  | j                  j	                  ||            S )N)r   r   )r   r   r   r   with_row_index)r}   r   r   	order_by_s       r   r   zLazyFrame.with_row_index  sH     #-Xs";XJ	##!!00" 1 
 	
r   r   r   ztype[DataFrame[Any]])r   r   r   r   r   )r   z+IntoBackend[Polars | Pandas | Arrow] | Noner   r   r   rh   r   )   r   intr   rQ   r   r   r   r   r   r   rQ   )index)r   r   r   zstr | Sequence[str] | Noner   rQ   )r   r   r   r   NwLazyFramer{   r   r   r   r   r   r   r   r   r   r   s   @r   r   r      s    * *  @ FJFBFUXF	F
-	
 "	
MQ	
	
0J	
		
r   r   c                       e Zd Zej                  Z ee      	 	 	 	 	 	 d fd       Ze		 d	 	 	 	 	 	 	 	 	 d fd       Z
e		 d	 	 	 	 	 	 	 	 	 d fd       Zedd       Zd fdZddddd	 	 	 	 	 	 	 	 	 d fd	Z	 ddd
d	 	 	 	 	 	 	 d fdZ xZS )r'   c               d    |j                   t        j                  u sJ t        |   ||       y ru   rw   )r}   seriesrv   r   s      r   r{   zSeries.__init__!  s-     '**,,,u-r   Nc               B    t         |   ||||      }t        d|      S Nr   rm   r   r   r   valuesdtyper   r   r   s         r   r   zSeries.from_numpy+  s*     #D&%#IM6**r   c               B    t         |   ||||      }t        d|      S r  )rz   from_iterabler
   r  s         r   r
  zSeries.from_iterable7  s*     &tVUG&LM6**r   c                    t         S r   r   r   s    r   r   zSeries._dataframeC  r   r   c                2    t        t        | 	               S r   )r   rz   to_framer   s    r   r  zSeries.to_frameG  s    %'*,--r   Fsortparallelr   	normalizec               <    t        t        | 	  ||||            S )Nr  )r   rz   value_counts)r}   r  r  r   r  r   s        r   r  zSeries.value_countsJ  s-     G H49 ! 
 	
r   T)	bin_countinclude_breakpointc               b    ddl m} d}t        ||       t        t        |   |||            S )Nr   )NarwhalsUnstableWarningzZ`Series.hist` is being called from the stable API although considered an unstable feature.)binsr  r  )narwhals.exceptionsr  r   r   rz   hist)r}   r  r  r  r  r   r   s         r   r  zSeries.histX  sF     	@# 	 	c23GLYCU  
 	
r   )r  r   rv   r   r   r   r   )
r   r   r  re   r  IntoDType | Noner   r   r   rm   )
r   r   r  zIterable[Any]r  r  r   r   r   rm   r   )r   rh   )
r  r   r  r   r   z
str | Noner  r   r   rh   )r  zlist[float] | Noner  
int | Noner  r   r   rh   )r   r   r   r   ry   rx   r   NwSeriesr{   r   r   r
  r   r   r  r  r  r   r   s   @r   r'   r'     sm   zzH..%K.	. . 
 #'		+	+ 	+  		+ +	+ 
	+ 	+ 
 #'		+	+ 	+  		+ +	+ 
	+ 	+  . 
 
 	

 
 
 

  $(
 !%#'
 
 	

 !
 

 
r   r'   c                       e Zd Zd fdZdddZdddZdddZddddZddd	dd
ZddZ	ddZ
ddZ	 ddddd	 	 	 	 	 	 	 	 	 ddZ xZS )r!   c                     t         |          S r   )rz   _taxicab_normr   s    r   r   zExpr._l1_normn  s    w$&&r   c                0      j                   fd      S )zGet the first `n` rows.c                D    j                  |       j                        S r   )_to_compliant_exprheadplxr   r}   s    r   <lambda>zExpr.head.<locals>.<lambda>t      //499!< r   _with_orderable_filtrationr}   r   s   ``r   r$  z	Expr.headq      ..<
 	
r   c                0      j                   fd      S )r   c                D    j                  |       j                        S r   )r#  r   r%  s    r   r'  zExpr.tail.<locals>.<lambda>z  r(  r   r)  r+  s   ``r   r   z	Expr.tailw  r,  r   c                4      j                   fd      S )zTake every nth value in the Series and return as new Series.

        Arguments:
            n: Gather every *n*-th row.
            offset: Starting index.
        c                H    j                  |       j                        S )Nr   )r#  r   )r&  r   r   r}   s    r   r'  z#Expr.gather_every.<locals>.<lambda>  s"    //4AAAfAU r   r)  r   s   ```r   r   zExpr.gather_every}  s     ..U
 	
r   N)maintain_orderc               T     |d}t        |t                j                   fd      S )z(Return unique values of this expression.zx`maintain_order` has no effect and is only kept around for backwards-compatibility. You can safely remove this argument.c                B    j                  |       j                         S r   )r#  uniquer&  r}   s    r   r'  zExpr.unique.<locals>.<lambda>  s    1H1H1M1T1T1V r   )r   UserWarning_with_filtration)r}   r1  r   s   `  r   r4  zExpr.unique  s1    %7  #{+$$%VWWr   F
descending
nulls_lastc               4      j                   fd      S )z*Sort this column. Place null values first.c                H    j                  |       j                        S )Nr8  )r#  r  )r&  r9  r:  r}   s    r   r'  zExpr.sort.<locals>.<lambda>  s'    //499%* :  r   )_with_window)r}   r9  r:  s   ```r   r  z	Expr.sort  s      
 	
r   c                ,      j                   fd      S )z'Returns the index of the maximum value.c                B    j                  |       j                         S r   )r#  arg_maxr5  s    r   r'  zExpr.arg_max.<locals>.<lambda>      //4<<> r   _with_orderable_aggregationr   s   `r   r@  zExpr.arg_max      //>
 	
r   c                ,      j                   fd      S )z'Returns the index of the minimum value.c                B    j                  |       j                         S r   )r#  arg_minr5  s    r   r'  zExpr.arg_min.<locals>.<lambda>  rA  r   rB  r   s   `r   rG  zExpr.arg_min  rD  r   c                ,      j                   fd      S )z/Find elements where boolean expression is True.c                B    j                  |       j                         S r   )r#  arg_truer5  s    r   r'  zExpr.arg_true.<locals>.<lambda>  s    //4==? r   r)  r   s   `r   rJ  zExpr.arg_true  s    ..?
 	
r   fractionwith_replacementseedc               <      j                   fd      S )a  Sample randomly from this expression.

        Arguments:
            n: Number of items to return. Cannot be used with fraction.
            fraction: Fraction of items to return. Cannot be used with n.
            with_replacement: Allow values to be sampled more than once.
            seed: Seed for the random number generator. If set to None (default), a random
                seed is generated for each sample operation.
        c                L    j                  |       j                        S )NrK  )r#  sample)r&  rL  r   rN  r}   rM  s    r   r'  zExpr.sample.<locals>.<lambda>  s,    //4;;H7Gd <  r   )r7  )r}   r   rL  rM  rN  s   `````r   rQ  zExpr.sample  s    " $$
 	
r   r   )
   r   r   r   )r1  bool | Noner   rQ   )r9  r   r:  r   r   rQ   r   )
r   r  rL  zfloat | NonerM  r   rN  r  r   rQ   )r   r   r   r   r$  r   r   r4  r  r@  rG  rJ  rQ  r   r   s   @r   r!   r!   m  s    '

	
 7; X */5 



 
 "&!&

 	

 
 
 

r   r!   c                  X     e Zd Zej                  Z ee      	 d	 	 	 d fd       Z xZ	S )r%   c                $    t         |   |       y r   )rz   r{   )r}   r   r   s     r   r{   zSchema.__init__  s     	 r   r   )r   z8Mapping[str, DType] | Iterable[tuple[str, DType]] | Noner   r   )
r   r   r   r   ry   rx   r   NwSchemar{   r   r   s   @r   r%   r%     s6    zzHQU!N!	! !r   r%   c                     y r   r   objs    r   r   r         ORr   c                     y r   r   rX  s    r   r   r     rZ  r   c                     y r   r   rX  s    r   r   r         CFr   c                     y r   r   rX  s    r   r   r     s    %(r   c                N   t        | t              r>t        | j                  j	                  t
        j                        | j                        S t        | t              r>t        | j                  j	                  t
        j                        | j                        S t        | t              r>t        | j                  j	                  t
        j                        | j                        S t        | t              r t        | j                  | j                         S t#        |        y ru   )r   r   r   r   _with_versionr   ry   _levelr   r   r  r'   _compliant_seriesNwExprr!   r#  	_metadatar   rX  s    r   r   r     s     #{#--;;GJJGszzZZ#{#--;;GJJGszzZZ#x c++99'**ESZZXX#vC**CMM::r   c                     y r   r   native_objectkwdss     r   from_nativeri    s    ADr   c                     y r   r   rf  s     r   ri  ri        GJr   c                     y r   r   rf  s     r   ri  ri    rk  r   c                     y r   r   rf  s     r   ri  ri    s     "r   .)
eager_onlyseries_onlyc                    y r   r   rg  strictrn  eager_or_interchange_onlyro  allow_seriess         r   ri  ri         7:r   )rs  ro  c                    y r   r   rq  s         r   ri  ri    ru  r   )rn  ro  rt  c                    y r   r   rq  s         r   ri  ri         !$r   c                    y r   r   rq  s         r   ri  ri         	r   )rs  ro  rt  c                    y r   r   rq  s         r   ri  ri  +  rx  r   c                    y r   r   rq  s         r   ri  ri  7  rz  r   )rn  rs  ro  c                    y r   r   rq  s         r   ri  ri  C  	     SVr   )rn  rs  rt  c                    y r   r   rq  s         r   ri  ri  O       r   )rn  rs  ro  rt  c                    y r   r   rq  s         r   ri  ri  [  rx  r   c                    y r   r   rq  s         r   ri  ri  g  rx  r   c                    y r   r   rq  s         r   ri  ri  s  rz  r   )rr  rn  ro  rt  c                    y r   r   rq  s         r   ri  ri    rx  r   )rr  rn  rs  ro  rt  c                    y r   r   rq  s         r   ri  ri    rx  r   )rr  rs  ro  rt  c                    y r   r   rq  s         r   ri  ri    rx  r   )rr  rn  rs  ro  c                    y r   r   rq  s         r   ri  ri         58r   )rr  rn  rs  rt  c                    y r   r   rq  s         r   ri  ri    r  r   c                    y r   r   rq  s         r   ri  ri    rx  r   c                    y r   r   rg  pass_throughrn  rs  ro  rt  s         r   ri  ri    rx  r   c                    y r   r   r  s         r   ri  ri    ru  r   c                    y r   r   r  s         r   ri  ri    rx  r   c                    y r   r   r  s         r   ri  ri    rz  r   c                    y r   r   r  s         r   ri  ri    rx  r   c                    y r   r   r  s         r   ri  ri    rz  r   c                    y r   r   r  s         r   ri  ri    r~  r   c                    y r   r   r  s         r   ri  ri    r  r   c                    y r   r   r  s         r   ri  ri  '  s     =@r   c                    y r   r   r  s         r   ri  ri  3  rz  r   )r  rn  ro  rt  c                    y r   r   r  s         r   ri  ri  ?  rx  r   )r  rs  ro  rt  c                    y r   r   r  s         r   ri  ri  K  rx  r   )r  rn  rs  ro  c                    y r   r   r  s         r   ri  ri  W  r  r   )r  rn  rs  rt  c                    y r   r   r  s         r   ri  ri  c  r  r   r  rn  rs  ro  rt  c                    y r   r   r  s         r   ri  ri  o  rx  r   c                    y r   r   r  s         r   ri  ri  {  rx  r   F)rs  c                    y r   r   r  s         r   ri  ri    s     r   )rr  r  rn  rs  ro  rt  c          	        t        | t        t        f      r|s| S t        | t              r|s|r| S t	        ||d      }|r"dt        t        |            }t        |      t        | |||||t        j                        S )aC  Convert `native_object` to Narwhals Dataframe, Lazyframe, or Series.

    See `narwhals.from_native` for full docstring. Note that `native_namespace` is
    an is the same as `backend` but only accepts module types - for new code, we
    recommend using `backend`, as that's available beyond just `narwhals.stable.v1`.
    Fpass_through_defaultz1from_native() got an unexpected keyword argument )r  rn  rs  ro  rt  version)r   r   r   r'   r   nextiterr   rI   r   ry   )	rg  rr  r  rn  rs  ro  rt  rh  r   s	            r   ri  ri    s    . -)Y!78-(k\25L A$tDzBRAUVn!";!

 r   )rr  c                    y r   r   narwhals_objectrr  s     r   	to_nativer         r   c                    y r   r   r  s     r   r  r    r  r   c                    y r   r   r  s     r   r  r         r   c                    y r   r   r  s     r   r  r    s    =@r   r  c                    y r   r   r  r  s     r   r  r    r  r   c                    y r   r   r  s     r   r  r    r  r   c                    y r   r   r  s     r   r  r    r  r   c                    y r   r   r  s     r   r  r    r]  r   )rr  r  c               R    ddl m}  |||d      }t        j                  | |      S )a#  Convert Narwhals object to native one.

    See `narwhals.to_native` for full docstring. Note that `native_namespace` is
    an is the same as `backend` but only accepts module types - for new code, we
    recommend using `backend`, as that's available beyond just `narwhals.stable.v1`.
    r   r   Fr  r  )narwhals._utilsr   nwr  )r  rr  r  r   s       r   r  r    s,     @25L <<lCCr   Tc               T    t        |d      dfd}| |S  ||       S )a1  Decorate function so it becomes dataframe-agnostic.

    See `narwhals.narwhalify` for full docstring. Note that `native_namespace` is
    an is the same as `backend` but only accepts module types - for new code, we
    recommend using `backend`, as that's available beyond just `narwhals.stable.v1`.
    Tr  c                <     t               d fd       }|S )Nc                    | D cg c]  }t        |
       } }|j                         D ci c]  \  }}|t        |
       }}}g | |j                         D ch c]  }t        |dd       x}r |        }}|j	                         dkD  rd}t        |       | i |}	t        |	      S c c}w c c}}w c c}w )Nr  __native_namespace__   z_Found multiple backends. Make sure that all dataframe/series inputs come from the same backend.r  )ri  itemsr  getattr__len__
ValueErrorr  )argsr   r   r   valuevbbackendsr   r   rt  rn  rs  funcr  ro  s             r   wrapperz.narwhalify.<locals>.decorator.<locals>.wrapper  s     
  !-).G +!-
D 
* $*<<>
  D% k!-).G +!- 
F 
 342&--/2 $:DAAAA H  !A%w o%4*6*FV,??I

s   B=C)C)r  r   r   r   r   r   r   )r  r  rt  rn  rs  r  ro  s   ` r   	decoratorznarwhalify.<locals>.decorator
  s)    	t%	@ %	@ 
%	@N r   )r  Callable[..., Any]r   r  r  )r  rr  r  rn  rs  ro  rt  r  s     ````` r   
narwhalifyr    s8      34L) )V |T?r   c                 <    t        t        j                               S r   )r   r  r   r   r   r   r   r   ;      bffhr   c                 8    t        t        j                  |        S r   )r   r  colnamess    r   r  r  ?  s    bffen%%r   c                 8    t        t        j                  |        S r   )r   r  excluder  s    r   r  r  C  s    bjj%())r   c                 8    t        t        j                  |        S r   )r   r  nth)indicess    r   r  r  G      bffg&''r   c                 <    t        t        j                               S r   )r   r  lenr   r   r   r  r  K  r  r   c                @    t        t        j                  | |            S r   )r   r  lit)r  r  s     r   r  r  O  s    bffUE*++r   c                 8    t        t        j                  |        S r   )r   r  mincolumnss    r   r  r  S  r  r   c                 8    t        t        j                  |        S r   )r   r  maxr  s    r   r  r  W  r  r   c                 8    t        t        j                  |        S r   )r   r  meanr  s    r   r  r  [  s    bggw'((r   c                 8    t        t        j                  |        S r   )r   r  medianr  s    r   r  r  _  s    bii)**r   c                 8    t        t        j                  |        S r   )r   r  sumr  s    r   r  r  c  r  r   c                 8    t        t        j                  |        S r   )r   r  sum_horizontalexprss    r   r  r  g      b''/00r   )ignore_nullsc                >    t        t        j                  |d| i      S Nr  )r   r  all_horizontalr  r  s     r   r  r  k       b''J\JKKr   c                >    t        t        j                  |d| i      S r  )r   r  any_horizontalr  s     r   r  r  q  r  r   c                 8    t        t        j                  |        S r   )r   r  mean_horizontalr  s    r   r  r  w  s    b((%011r   c                 8    t        t        j                  |        S r   )r   r  min_horizontalr  s    r   r  r  {  r  r   c                 8    t        t        j                  |        S r   )r   r  max_horizontalr  s    r   r  r    r  r    	separatorr  c               H    t        t        j                  | g|||d      S )Nr  )r   r  
concat_str)r  r  r  
more_exprss       r   r  r    s)     
eYjYILY r   c                @    t        t        j                  | g|       S r   )r   r  coalesce)r  r  s     r   r  r    s    bkk%5*566r   c                    | j                   S )a  Level of support Narwhals has for current object.

    Arguments:
        obj: Dataframe or Series.

    Returns:
        This can be one of

            - 'full': full Narwhals API support
            - 'lazy': only lazy operations are supported. This excludes anything
              which involves iterating over rows in Python.
            - 'interchange': only metadata operations are supported (`df.schema`)
    )ra  rX  s    r   	get_levelr    s      ::r   c                  2     e Zd Zedd       Zd fdZ xZS )Whenc                &     | |j                         S r   )
_predicate)r   whens     r   	from_whenzWhen.from_when  s    4??##r   c                H    t         j                  t        |   |            S r   )Then	from_thenrz   thenr}   r  r   s     r   r  z	When.then  s    ~~egl5122r   )r  z	nw_f.Whenr   r  )r  &IntoExpr | NonNestedLiteral | _1DArrayr   r  )r   r   r   r   r	  r  r   r   s   @r   r  r    s    $ $3 3r   r  c                  2     e Zd Zedd       Zd fdZ xZS )r  c                <     | |j                   |j                        S r   )r#  rd  )r   r  s     r   r  zThen.from_then  s    4**DNN;;r   c                4    t        t        | 	  |            S r   )r   rz   	otherwiser  s     r   r  zThen.otherwise  s    %'+E233r   )r  z	nw_f.Thenr   r  )r  r  r   r!   )r   r   r   r   r  r  r   r   s   @r   r  r    s    < <4 4r   r  c                 L    t         j                  t        j                  |        S r   )r  r	  nw_fr  )
predicatess    r   r  r    s    >>$))Z011r   )required)r   native_namespacec               J    t        d|      }t        t        | |||            S )a=  Instantiate Narwhals Series from iterable (e.g. list or array).

    See `narwhals.new_series` for full docstring. Note that `native_namespace` is
    an is the same as `backend` but only accepts module types - for new code, we
    recommend using `backend`, as that's available beyond just `narwhals.stable.v1`.
    r   r   )r
   r   r"   )r   r  r  r   r  s        r   
new_seriesr    s(     .8G&tVUGLMMr   c               Z    t        d|      }t        t        j                  | |            S )aJ  Construct a DataFrame from an object which supports the PyCapsule Interface.

    See `narwhals.from_arrow` for full docstring. Note that `native_namespace` is
    an is the same as `backend` but only accepts module types - for new code, we
    recommend using `backend`, as that's available beyond just `narwhals.stable.v1`.
    r   r   )r
   r   r  r   )r   r   r  s      r   r   r     s'     .8GdoolGDEEr   c               D    t        t        j                  | ||            S )a#  Instantiate DataFrame from dictionary.

    See `narwhals.from_dict` for full docstring. Note that `native_namespace` is
    an is the same as `backend` but only accepts module types - for new code, we
    recommend using `backend`, as that's available beyond just `narwhals.stable.v1`.
    r   )r   r  r   r   r   r   r  s       r   r   r     s     dnnT67CDDr   c               \    t        d|      }t        t        j                  | ||            S )a)  Construct a DataFrame from a NumPy ndarray.

    See `narwhals.from_numpy` for full docstring. Note that `native_namespace` is
    an is the same as `backend` but only accepts module types - for new code, we
    recommend using `backend`, as that's available beyond just `narwhals.stable.v1`.
    r   r   )r
   r   r  r   r  s       r   r   r     s)     .8GdoodFGDEEr   c               \    t        d|      }t        t        j                  | fd|i|      S )a  Read a CSV file into a DataFrame.

    See `narwhals.read_csv` for full docstring. Note that `native_namespace` is
    an is the same as `backend` but only accepts module types - for new code, we
    recommend using `backend`, as that's available beyond just `narwhals.stable.v1`.
    r   r   )r
   r   r  read_csvsourcer   r  r   s       r   r   r     s/     .8GdmmFFGFvFGGr   c               \    t        d|      }t        t        j                  | fd|i|      S )a  Lazily read from a CSV file.

    See `narwhals.scan_csv` for full docstring. Note that `native_namespace` is
    an is the same as `backend` but only accepts module types - for new code, we
    recommend using `backend`, as that's available beyond just `narwhals.stable.v1`.
    IntoBackend[Backend]r   )r
   r   r  scan_csvr!  s       r   r%  r%    s/     )73GdmmFFGFvFGGr   c               \    t        d|      }t        t        j                  | fd|i|      S )a*  Read into a DataFrame from a parquet file.

    See `narwhals.read_parquet` for full docstring. Note that `native_namespace` is
    an is the same as `backend` but only accepts module types - for new code, we
    recommend using `backend`, as that's available beyond just `narwhals.stable.v1`.
    r   r   )r
   r   r  read_parquetr!  s       r   r'  r'  &  s1     .8Gd''JJ6JKKr   c               \    t        d|      }t        t        j                  | fd|i|      S )a   Lazily read from a parquet file.

    See `narwhals.scan_parquet` for full docstring. Note that `native_namespace` is
    an is the same as `backend` but only accepts module types - for new code, we
    recommend using `backend`, as that's available beyond just `narwhals.stable.v1`.
    r$  r   )r
   r   r  scan_parquetr!  s       r   r)  r)  8  s1     )73Gd''JJ6JKKr   )Qr+   r,   r-   r.   r   r/   r0   r1   r2   r3   r!   r4   r5   r6   r   r7   r8   r9   r:   r;   r   r<   r=   r%   r'   r>   r?   r@   rA   rB   rC   rD   rE   rF   r   r  r  r  r  r#   r  r(   r)   r   r  r   r   ri  r   r   r  rJ   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  rK   r  )rY  zNwDataFrame[IntoDataFrameT]r   DataFrame[IntoDataFrameT])rY  zNwLazyFrame[IntoLazyFrameT]r   LazyFrame[IntoLazyFrameT])rY  zNwSeries[IntoSeriesT]r   Series[IntoSeriesT])rY  rc  r   r!   )rY  zZNwDataFrame[IntoDataFrameT] | NwLazyFrame[IntoLazyFrameT] | NwSeries[IntoSeriesT] | NwExprr   zRDataFrame[IntoDataFrameT] | LazyFrame[IntoLazyFrameT] | Series[IntoSeriesT] | Expr)rg  rl   rh  r   r   rl   )rg  rg   rh  r   r   rg   )rg  rj   rh  r   r   rj   )rg  DataFrameT | LazyFrameTrh  r   r   r-  )rg  IntoDataFrameT | IntoSeriesTrr  r   rn  r   rs  r   ro  r   rt  r   r   /DataFrame[IntoDataFrameT] | Series[IntoSeriesT])rg  r.  rr  r   rn  r   rs  r   ro  r   rt  r   r   r/  )rg  rG   rr  r   rn  r   rs  r   ro  r   rt  r   r   r*  )rg  rn   rr  r   rn  r   rs  r   ro  r   rt  r   r   rn   )rg  rG   rr  r   rn  r   rs  r   ro  r   rt  r   r   r*  )rg  rn   rr  r   rn  r   rs  r   ro  r   rt  r   r   rn   )rg  -IntoDataFrameT | IntoLazyFrameT | IntoSeriesTrr  r   rn  r   rs  r   ro  r   rt  r   r   KDataFrame[IntoDataFrameT] | LazyFrame[IntoLazyFrameT] | Series[IntoSeriesT])rg  rr   rr  r   rn  r   rs  r   ro  r   rt  r   r   r,  )rg  rG   rr  r   rn  r   rs  r   ro  r   rt  r   r   r*  )rg  rH   rr  r   rn  r   rs  r   ro  r   rt  r   r   r+  )rg  rn   rr  r   rn  r   rs  r   ro  r   rt  r   r   rn   )rg  rG   rr  Literal[True] | Nonern  r   rs  r   ro  r   rt  r   r   r*  )rg  rH   rr  r2  rn  r   rs  r   ro  r   rt  r   r   r+  )rg  rG   rr  r2  rn  r   rs  r   ro  r   rt  r   r   r*  )rg  IntoFrame | IntoSeriesrr  r2  rn  r   rs  r   ro  r   rt  r   r   -DataFrame[Any] | LazyFrame[Any] | Series[Any])rg  rr   rr  r2  rn  r   rs  r   ro  r   rt  r   r   r,  )rg  rG   rr  r2  rn  r   rs  r   ro  r   rt  r   r   r*  )rg  zIntoDataFrameT | IntoSeriesr  r   rn  r   rs  r   ro  r   rt  r   r   r*  )rg  r.  r  r   rn  r   rs  r   ro  r   rt  r   r   r/  )rg  rG   r  r   rn  r   rs  r   ro  r   rt  r   r   r*  )rg  rn   r  r   rn  r   rs  r   ro  r   rt  r   r   rn   )rg  rG   r  r   rn  r   rs  r   ro  r   rt  r   r   r*  )rg  rn   r  r   rn  r   rs  r   ro  r   rt  r   r   rn   )rg  r0  r  r   rn  r   rs  r   ro  r   rt  r   r   r1  )rg  rr   r  r   rn  r   rs  r   ro  r   rt  r   r   r,  )rg  zIntoDataFrameT | IntoLazyFrameTr  r   rn  r   rs  r   ro  r   rt  r   r   z5DataFrame[IntoDataFrameT] | LazyFrame[IntoLazyFrameT])rg  rn   r  r   rn  r   rs  r   ro  r   rt  r   r   rn   )rg  rG   r  r   rn  r   rs  r   ro  r   rt  r   r   r*  )rg  rG   r  r   rn  r   rs  r   ro  r   rt  r   r   r*  )rg  r3  r  r   rn  r   rs  r   ro  r   rt  r   r   r4  )rg  rr   r  r   rn  r   rs  r   ro  r   rt  r   r   r,  )rg  rG   r  r   rn  r   rs  r   ro  r   rt  r   r   r*  )rg  rH   r  r   rn  r   rs  r   ro  r   rt  r   r   r+  )rg  r   r  r   rn  r   rs  r   ro  r   rt  rS  r   r   )rg  zJIntoDataFrameT | IntoLazyFrameT | IntoFrame | IntoSeriesT | IntoSeries | Trr  rS  r  rS  rn  r   rs  r   ro  r   rt  rS  rh  r   r   zOLazyFrame[IntoLazyFrameT] | DataFrame[IntoDataFrameT] | Series[IntoSeriesT] | T)r  r*  rr  r   r   rG   )r  r+  rr  r   r   rH   )r  r,  rr  r   r   rr   )r  r   rr  r   r   r   )r  r*  r  r   r   rG   )r  r+  r  r   r   rH   )r  r,  r  r   r   rr   )r  r   r  r   r   r   )r  r1  rr  rS  r  rS  r   z3IntoLazyFrameT | IntoDataFrameT | IntoSeriesT | Anyr   )r  zCallable[..., Any] | Nonerr  rS  r  rS  rn  r   rs  r   ro  r   rt  rS  r   r  )r   r!   )r  zstr | Iterable[str]r   r!   )r  zint | Sequence[int]r   r!   )r  rb   r  r  r   r!   )r  r   r   r!   )r  IntoExpr | Iterable[IntoExpr]r   r!   )r  r5  r  r   r   r!   )
r  r5  r  r_   r  r   r  r   r   r!   )r  r5  r  r_   r   r!   )rY  z5DataFrame[Any] | LazyFrame[Any] | Series[IntoSeriesT]r   r   )r  r5  r   r  )r   r   r  r   r  r  r   r   r  ModuleType | Noner   rm   )r   rR   r   r   r  r6  r   rh   )
r   r   r   r   r   r   r  r6  r   rh   )
r   rf   r   r   r   r   r  r6  r   rh   )
r"  r]   r   r   r  r6  r   r   r   rh   )
r"  r]   r   zIntoBackend[Backend] | Noner  r6  r   r   r   rk   )
__future__r   	functoolsr   typingr   r   r   r	   r
   r   narwhalsr  r   r   r  narwhals._exceptionsr   narwhals._typing_compatr   r   r  r   r   r   r   r   r   r   r   r   r   r   r   narwhals.dataframer   r   r   r   r  r   r   r!   rc  narwhals.functionsr"   r#   r$   narwhals.schemar%   rV  r   r'   r  narwhals.stable.v1r(   r)   r*   narwhals.stable.v1.dtypesr+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   narwhals.stable.v1.typingrG   rH   narwhals.translaterI   rJ   rK   collections.abcrL   rM   rN   typesrO   typing_extensionsrP   rQ   narwhals._translaterR   narwhals._typingrS   rT   rU   rV   rW   rX   rY   rZ   r[   narwhals.dtypesr\   narwhals.typingr]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rj   rl   rn   rp   rq   rr   r   ri  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'  r)  __all__r   r   r   <module>rL     s   "  H H  2 . 9    R 4 ( F F . . > >       < E T T;; 12   H%   -=>J-=>Ji}5GS!A#AAm<Ev-N+ v-r8
N+ 8
vL
Xk" L
^T
6 T
n!X ! 
 R 
 R	 R 
 R	 F 
 F	 ( 
 (

 X" 
 D 
 D 
 J 
 J 
 J 
 J 
"*"47"" 
"
 

 "%"%:/: : 	:
  -:  :  : 5: 
: 
 14"%:/: : 	:
  .:  :  : 5: 
: 

 "%"%$!$ $ 	$
  -$  $ $ $ 
$ 

 "%"%  	
  -     
 
 14"%$!$ $ 	$
  .$  $ $ $ 
$ 
 14"%  	
  .     
 

 "%03"%V@V V 	V
  .V  V  V QV 
V 

 "%03  	
  .    
 

 "%03"%$!$ $ 	$
  .$  $ $ $ 
$ 

 "%03"%$!$ $ 	$
  .$  $ $ $ 
$ 

 "%03"%  	
  .     
 
 $'!$"%$!$ !$ 	$
  -$  $ $ $ 
$ 
 $'!$03"%$!$ !$ 	$
  .$  $ $ $ 
$ 
 $'03"%$!$ !$ 	$
  .$  $ $ $ 
$ 
 $'!$03"%8)8 !8 	8
  .8  8  8 38 
8 
 $'!$03 ! 	
  .    
 
 $'!$03"%$!$ !$ 	$
  .$  $ $ $ 
$ 

 "%"%$.$  $ 	$
  -$  $  $ $ 
$ 
 14"%:/:  : 	:
  .:  :  : 5: 
: 

 "%"%$!$  $ 	$
  -$  $ $ $ 
$ 

 "%"%   	
  -     
 
 14"%$!$  $ 	$
  .$  $ $ $ 
$ 
 14"%   	
  .     
 

 "%03"%V@V  V 	V
  .V  V  V QV 
V 

 "%03   	
  .    
 

 "%03"%@2@  @ 	@
  .@  @ @ ;@ 
@ 

 "%03"%   	
  .     
 
 $'!$"%$!$ !$ 	$
  -$  $ $ $ 
$ 
 $'03"%$!$ !$ 	$
  .$  $ $ $ 
$ 
 $'!$03"%8)8 !8 	8
  .8  8  8 38 
8 
 $'!$03 ! 	
  .    
 
 $'!$03"%$!$ !$ 	$
  .$  $ $ $ 
$ 
 $'!$03"%$!$ !$ 	$
  .$  $ $ $ 
$ 
 ',  	
  $   	 
&  $&+ $++ + + +  $+ + + + U+\ 
KN.;H 
 
KN.;H 
 
EH(5B 
 
 @ 
 @	RU.AO 
 
RU.AO 
 
LO(;I 
 
 F 
 F  $DD
 D D 9D. '+B  $&+ $B
#B B 	B
 B  $B B B BJ &*( ,(()+(1
 AFL)L9=L	L AFL)L9=L	L211 	(  	
 
7	>+&3499 34499d 42 T* #N
 15*.N
NN N
 .N (N N +N$ T* 15*.	F F .F (	F
 F +F   37E 15*.E
E/E .	E
 (E E E  T* CGF 15*.F
F?F .	F
 (F F +F" T* 15*.	HH .H (	H
 H H +H" T* ,0*.	HH )H (	H
 H H +H" T* 15*.	LL .L (	L
 L L +L" T* ,0*.	LL )L (	L
 L L +L"Rr   