
    hh                       U 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
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/m0Z0 d dl1m2Z3 d dl4m5Z6 d dl7m8Z8m9Z9m:Z: d dl;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZW d dlXmYZYmZZZ d dl[m\Z\m]Z]m^Z^ erd dl_m`Z`maZambZb d dlcmdZd d dlemfZfmgZg d dlhmiZi d dljmkZkmlZlmmZmmnZnmoZompZpmqZq d dl#mrZrmsZs d dltmuZu d dlvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~mZmZmZ  edd          Z edd          Z ed d!          Z ed"e#          Z efd$          Z ed%          Z ed&d'e(          Z G d) d*e%eY                   Z$ G d+ d,e'eZ                   Z& G d- d.e6e                   Z5 G d/ d0e,          Z+ G d1 d2e3          Z2ed d7            Zedd:            Zedd=            Zedd?            ZddBZeddF            ZeddG            ZeddH            ZeddJ            ZedKdKdLd	dV            ZedKdKdWd
dX            ZedKdKdKdYdd\            ZedKdKdKdYdd]            ZedKdKdKd^dd_            ZedKdKdKd^dd`            ZedKdKdKdaddd            ZedKdKdKdeddf            ZedKdKdKdKdgddh            ZedKdKdKdKdgddj            ZedKdKdKdKdgddk            ZedKdKdKdKdlddn            ZedKdKdKdKdKdoddp            ZedKdKdKdKdqddr            ZedKdKdKdKdsddv            ZedKdKdKdKdwddx            ZedKdKdKdKdKdoddy            ZedKdKdLdd|            ZedKdKdWdd}            ZedKdKdKdYdd~            ZedKdKdKdYdd            ZedKdKdKd^dd            ZedKdKdKd^dd            ZedKdKdKdad d            ZedKdKdKded!d            ZedKdKdKdKdgd"d            ZedKdKdKdKdgd#d            ZedKdKdKdKdd$d            ZedKdKdKdKdd%d            ZedKdKdKdKdd&d            ZedKdKdKdKdd'd            ZedKdKdKdKdKdd(d            ZedKdKdKdKdKdd)d            Zeddd*d            Zdddddddd+dZedKdd,d            ZedKdd-d            ZedKdd.d            Zed/d            ZedKdd0d            ZedKdd1d            ZedKdd2d            Zed3d            Zdddd4dZ	 d5dddddddd6dZd7dZd8dZd8dZd9dZd7dZd5d:dZd;dZd;dZd;dZd;dZd;dÄZd<dƄZddǜd=dɄZddǜd=dʄZd<d˄Zd<d̄Zd<d̈́ZdddϜd>dӄZd?dքZd@dׄZdAdڄZ G dۄ dej                  Z G d݄ dej        e+          ZdBdZ ed          	 d5ddddCd            Z ed          ddddDd            Z e            	 d5ddddEd            Ze$j        Zded<    ed          	 d5ddddFd            Z ed          ddddGd            Z ed          ddddHd            Z ed          ddddGd            Z ed          ddddHd            Zg dZdS (I      )annotationswraps)TYPE_CHECKINGAnyCallableFinal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
IntoSchema
IntoSeriesNonNestedLiteralSingleColSelectorSingleIndexSelector_1DArray_2DArray
DataFrameTDataFrame[Any])bound
LazyFrameTLazyFrame[Any]SeriesTSeries[Any]T)defaultPRIntoSeriesTrc   )rk   rq   c                      e Zd Zej        Z ee          dG fd            Ze	dH fd            Z
e		 dIdddJ fd            Ze		 dIdK fd            Ze		 dIdL fd            ZedMd            ZedNd            ZedOd"            ZedPd%            ZedQd(            ZdR fd+ZdS fd/Z	 dIdd0dT fd5Zed6d7dUd;            ZedVd>            Zed?d7dWdB            Zd?d7dW fdCZdX fdDZdX fdEZdYdFZ xZS )Zr   dfr   level&Literal['full', 'lazy', 'interchange']returnNonec               x    |j         t          j        u sJ t                                          ||           d S N)rw   _versionr   V1super__init__selfrv   rw   	__class__s      R/var/www/histauto/venv/lib/python3.11/site-packages/narwhals/stable/v1/__init__.pyr   zDataFrame.__init__n   ;    {gj((((5)))))    native_framerS   backendIntoBackend[EagerAllowed]rj   c               j    t                                          ||          }t          d|          S Nr   rj   )r   
from_arrowr   )clsr   r   resultr   s       r   r   zDataFrame.from_arrowv   s2     ##L'#BB$f---r   Nr   dataMapping[str, Any]schema#Mapping[str, DType] | Schema | None IntoBackend[EagerAllowed] | Nonec               l    t                                          |||          }t          d|          S r   )r   	from_dictr   r   r   r   r   r   r   s        r   r   zDataFrame.from_dict}   s4     ""4"AA$f---r   Sequence[Any]IntoSchema | Nonec               l    t                                          |||          }t          d|          S r   )r   
from_dictsr   r   s        r   r   zDataFrame.from_dicts   4     ##D&'#BB$f---r   rh   3Mapping[str, DType] | Schema | Sequence[str] | Nonec               l    t                                          |||          }t          d|          S r   r   
from_numpyr   r   s        r   r   zDataFrame.from_numpy   r   r   type[Series[Any]]c                ,    t          dt                    S )Nr   )r   r(   r   s    r   _serieszDataFrame._series   s    '000r   type[LazyFrame[Any]]c                ,    t          dt                    S )Nr   )r   r   r   s    r   
_lazyframezDataFrame._lazyframe   s    *I666r   item-tuple[SingleIndexSelector, SingleColSelector]c                    d S N r   r   s     r   __getitem__zDataFrame.__getitem__   s    WZWZr   2str | tuple[MultiIndexSelector, SingleColSelector]ro   c                    d S r   r   r   s     r   r   zDataFrame.__getitem__   s	     cr   SingleIndexSelector | MultiIndexSelector | MultiColSelector | tuple[SingleIndexSelector, MultiColSelector] | tuple[MultiIndexSelector, MultiColSelector]rR   c                    d S r   r   r   s     r   r   zDataFrame.__getitem__   s	     sr     SingleIndexSelector | SingleColSelector | MultiColSelector | MultiIndexSelector | tuple[SingleIndexSelector, SingleColSelector] | tuple[SingleIndexSelector, MultiColSelector] | tuple[MultiIndexSelector, SingleColSelector] | tuple[MultiIndexSelector, MultiColSelector]Series[Any] | Self | Anyc                F    t                                          |          S r   )r   r   )r   r   r   s     r   r   zDataFrame.__getitem__   s     ww""4(((r   namestrr(   c                F    t                                          |          S r   )r   
get_column)r   r   r   s     r   r   zDataFrame.get_column   s     ww!!$'''r   )sessionIntoBackend[LazyAllowed] | Noner   
Any | Nonerm   c               d    t          t                                          ||                    S )N)r   r   )
_stableifyr   lazy)r   r   r   r   s      r   r   zDataFrame.lazy   s'     %'',,w,HHIIIr   .	as_seriesr   Literal[True]dict[str, Series[Any]]c                   d S r   r   r   r   s     r   to_dictzDataFrame.to_dict   s    TWTWr   Literal[False]dict[str, list[Any]]c                   d S r   r   r   s     r   r   zDataFrame.to_dict   s    MPSr   Tbool-dict[str, Series[Any]] | dict[str, list[Any]]c                   d S r   r   r   s     r   r   zDataFrame.to_dict   s	     9<r   c               H    t                                          |          S )Nr   )r   r   )r   r   r   s     r   r   zDataFrame.to_dict   s    
 ww333r   c                ^    t          t                                                                S r   )r   r   is_duplicatedr   r   s    r   r   zDataFrame.is_duplicated   s!    %''//11222r   c                ^    t          t                                                                S r   )r   r   	is_uniquer   s    r   r   zDataFrame.is_unique   s!    %''++--...r   c                h    |                      t                                                                S r   selectall_l1_normr   s    r   r   zDataFrame._l1_norm   "    {{355>>++,,,r   rv   r   rw   rx   ry   rz   )r   rS   r   r   ry   rj   r   )r   r   r   r   r   r   ry   rj   )r   r   r   r   r   r   ry   rj   )r   rh   r   r   r   r   ry   rj   )ry   r   )ry   r   )r   r   ry   r   )r   r   ry   ro   )r   r   ry   rR   )r   r   ry   r   )r   r   ry   r(   )r   r   r   r   ry   rm   )r   r   ry   r   )r   r   ry   r   )r   r   ry   r   )ry   ro   ry   rR   )__name__
__module____qualname__r   r   r~   r   NwDataFramer   classmethodr   r   r   r   propertyr   r   r   r   r   r   r   r   r   r   __classcell__r   s   @r   r   r   k   s!       zH[* * * * * * . . . . . [.  7;.
 59. . . . . . . [.  %). . . . . . [.  GK. . . . . . [. 1 1 1 X1 7 7 7 X7 ZZZ XZ   X 	 	 	 X	) ) ) ) ) )( ( ( ( ( ( 48J #	J J J J J J J J 47WWWWW XWPPP XP#'< < < < < X< $(4 4 4 4 4 4 4 43 3 3 3 3 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   rv   r   rw   rx   ry   rz   c               x    |j         t          j        u sJ t                                          ||           d S r|   r}   r   s      r   r   zLazyFrame.__init__   r   r   type[DataFrame[Any]]c                    t           S r   r   r   s    r   
_dataframezLazyFrame._dataframe       r   argc                   ddl m} ddlm} t	          ||          rd}t          |          t	          ||t          f          r)|                                                     |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   r   r"   r(   msgs        r   _extract_compliantzLazyFrame._extract_compliant   s     	'&&&&&******c6"" 	!BCC.. cD#;'' 	X..00@@QV@WWW"4T#YY???r   Nr   +IntoBackend[Polars | Pandas | Arrow] | Nonekwargsrj   c                T    t           t                      j        dd|i|          S )Nr   r   )r   r   collect)r   r   r   r   s      r   r   zLazyFrame.collect  s.     /%''/DD'DVDDEEEr   rR   c                h    |                      t                                                                S r   r   r   s    r   r   zLazyFrame._l1_norm  r   r      nintc                F    t                                          |          S )Get the last `n` rows.)r   tail)r   r   r   s     r   r  zLazyFrame.tail  s    ww||Ar   r   offsetc                `    |                      | 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   r  )_with_compliant_compliant_framegather_everyr   r   r  s      r   r  zLazyFrame.gather_every  s5     ##!..6.BB
 
 	
r   index)order_byr   r   r  str | Sequence[str] | Nonec                   t          |t                    r|gn|}|                     | 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  sW     #-Xs";";IXJJ	##!00" 1  
 
 	
r   r   ry   r   )r   r   ry   r   r   )r   r   r   r   ry   rj   r   )r   r   r   ry   rR   r   r   r   r  r   ry   rR   )r
  )r   r   r  r  ry   rR   )r   r   r   r   NwLazyFramer   r   r   r   r   r   r  r  r  r   r   s   @r   r   r      s6       [* * * * * *    X@ @ @ @ FJF F F F F F F
- - - -      	
 	
 	
 	
 	
 "	
MQ	
 	
 	
 	
 	
 	
 	
 	
 	
 	
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"d0 fd(Z xZS )1r(   seriesr   rw   rx   ry   rz   c               x    |j         t          j        u sJ t                                          ||           d S r|   r}   )r   r  rw   r   s      r   r   zSeries.__init__-  s=     '*,,,,u-----r   Nr   r   valuesrg   dtypeIntoDType | Noner   r   ro   c               n    t                                          ||||          }t          d|          S Nr   ro   r   r   r   r  r  r   r   r   s         r   r   zSeries.from_numpy7  s5     ##D&%#IIM6***r   Iterable[Any]c               n    t                                          ||||          }t          d|          S r  )r   from_iterabler   r  s         r   r   zSeries.from_iterableC  s5     &&tVUG&LLM6***r   r   c                    t           S r   r   r   s    r   r   zSeries._dataframeO  r   r   rj   c                ^    t          t                                                                S r   )r   r   to_framer   s    r   r#  zSeries.to_frameS  s!    %''**,,---r   Fsortparallelr   	normalizer%  r   r&  
str | Noner'  c               h    t          t                                          ||||                    S )Nr$  )r   r   value_counts)r   r%  r&  r   r'  r   s        r   r*  zSeries.value_countsV  s<     GG  H49 !  
 
 	
r   T)	bin_countinclude_breakpointbinslist[float] | Noner+  
int | Noner,  c                   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.)r-  r+  r,  )narwhals.exceptionsr1  r   r   r   hist)r   r-  r+  r,  r1  r   r   s         r   r3  zSeries.histd  si     	@?????# 	 	c2333GGLLYCU   
 
 	
r   )r  r   rw   rx   ry   rz   r   )
r   r   r  rg   r  r  r   r   ry   ro   )
r   r   r  r  r  r  r   r   ry   ro   r  )ry   rj   )
r%  r   r&  r   r   r(  r'  r   ry   rj   )r-  r.  r+  r/  r,  r   ry   rj   )r   r   r   r   r   r~   r   NwSeriesr   r   r   r   r   r   r#  r*  r3  r   r   s   @r   r(   r(   *  so       zH[. . . . . . 
 #'		+ 	+ 	+ 	+ 	+ 	+ [	+ 
 #'		+ 	+ 	+ 	+ 	+ 	+ [	+    X. . . . . . 
 
 
 
 
 
 
 
  $(
 !%#'
 
 
 
 
 
 
 
 
 
 
 
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"   ry   rR   c                D    t                                                      S r   )r   _taxicab_normr   s    r   r   zExpr._l1_normz  s    ww$$&&&r   
   r   r   c                8                            fd          S )zGet the first `n` rows.c                T                         |                                         S r   )_to_compliant_exprheadplxr   r   s    r   <lambda>zExpr.head.<locals>.<lambda>  #    //4499!<< r   _with_orderable_filtrationr   r   s   ``r   r<  z	Expr.head}  +    ..<<<<<
 
 	
r   c                8                            fd          S )r  c                T                         |                                         S r   )r;  r  r=  s    r   r?  zExpr.tail.<locals>.<lambda>  r@  r   rA  rC  s   ``r   r  z	Expr.tail  rD  r   r   r  c                <                            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                X                         |                                         S )Nr  )r;  r  )r>  r   r  r   s    r   r?  z#Expr.gather_every.<locals>.<lambda>  s(    //44AAAfAUU r   rA  r	  s   ```r   r  zExpr.gather_every  s1     ..UUUUUU
 
 	
r   N)maintain_orderrI  bool | Nonec               f     |d}t          |t                                           fd          S )z(Return unique values of this expression.Nzx`maintain_order` has no effect and is only kept around for backwards-compatibility. You can safely remove this argument.c                R                         |                                           S r   )r;  uniquer>  r   s    r   r?  zExpr.unique.<locals>.<lambda>  s!    1H1H1M1M1T1T1V1V r   )r   UserWarning_with_filtration)r   rI  r   s   `  r   rM  zExpr.unique  sC    %7  #{+++$$%V%V%V%VWWWr   F
descending
nulls_lastrR  r   rS  c               <                            fd          S )z*Sort this column. Place null values first.c                X                         |                                         S )NrQ  )r;  r%  )r>  rR  rS  r   s    r   r?  zExpr.sort.<locals>.<lambda>  s/    //4499%* :   r   )_with_window)r   rR  rS  s   ```r   r%  z	Expr.sort  s;           
 
 	
r   c                4                            fd          S )z'Returns the index of the maximum value.c                R                         |                                           S r   )r;  arg_maxrN  s    r   r?  zExpr.arg_max.<locals>.<lambda>  !    //44<<>> r   _with_orderable_aggregationr   s   `r   rY  zExpr.arg_max  '    //>>>>
 
 	
r   c                4                            fd          S )z'Returns the index of the minimum value.c                R                         |                                           S r   )r;  arg_minrN  s    r   r?  zExpr.arg_min.<locals>.<lambda>  rZ  r   r[  r   s   `r   r`  zExpr.arg_min  r]  r   c                4                            fd          S )z/Find elements where boolean expression is True.c                R                         |                                           S r   )r;  arg_truerN  s    r   r?  zExpr.arg_true.<locals>.<lambda>  s!    //44==?? r   rA  r   s   `r   rc  zExpr.arg_true  s'    ..????
 
 	
r   fractionwith_replacementseedr/  re  float | Nonerf  rg  c               D                            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                \                         |                                         S )Nrd  )r;  sample)r>  re  r   rg  r   rf  s    r   r?  zExpr.sample.<locals>.<lambda>  s4    //44;;H7Gd <   r   )rP  )r   r   re  rf  rg  s   `````r   rk  zExpr.sample  sI    " $$       
 
 	
r   r   )r8  r  r  r  )rI  rJ  ry   rR   )rR  r   rS  r   ry   rR   r   )
r   r/  re  rh  rf  r   rg  r/  ry   rR   )r   r   r   r   r<  r  r  rM  r%  rY  r`  rc  rk  r   r   s   @r   r"   r"   y  sE       ' ' ' ' ' '
 
 
 
 

 
 
 
 
	
 	
 	
 	
 	
 7; X X X X X X */5 
 
 
 
 
 

 
 
 

 
 
 

 
 
 
 
 "&!&
 
 
 
 
 
 
 
 
 
r   r"   c                  T     e Zd Zej        Z ee          	 dd fd            Z xZ	S )	r&   Nr   8Mapping[str, DType] | Iterable[tuple[str, DType]] | Nonery   rz   c                J    t                                          |           d S r   )r   r   )r   r   r   s     r   r   zSchema.__init__  s#     	     r   r   )r   rm  ry   rz   )
r   r   r   r   r   r~   r   NwSchemar   r   r   s   @r   r&   r&     sa        zH[QU! ! ! ! ! ! ! ! ! ! !r   r&   objNwDataFrame[IntoDataFrameT]ry   DataFrame[IntoDataFrameT]c                    d S r   r   rp  s    r   r   r         ORsr   NwLazyFrame[IntoLazyFrameT]LazyFrame[IntoLazyFrameT]c                    d S r   r   rt  s    r   r   r     ru  r   NwSeries[IntoSeriesT]Series[IntoSeriesT]c                    d S r   r   rt  s    r   r   r         CF3r   NwExprc                    d S r   r   rt  s    r   r   r     s    %(Sr   ZNwDataFrame[IntoDataFrameT] | NwLazyFrame[IntoLazyFrameT] | NwSeries[IntoSeriesT] | NwExprRDataFrame[IntoDataFrameT] | LazyFrame[IntoLazyFrameT] | Series[IntoSeriesT] | Exprc                P   t          | t                    r8t          | j                            t
          j                  | j                  S t          | t                    r8t          | j                            t
          j                  | j                  S t          | t                    r8t          | j                            t
          j                  | j                  S t          | t                    rt          | j        | j                  S t#          |            d S r|   )r   r   r   r  _with_versionr   r   _levelr  r   r4  r(   _compliant_seriesr}  r"   r;  	_metadatar   rt  s    r   r   r     s     #{## [-;;GJGGszZZZZ#{## [-;;GJGGszZZZZ#x   Yc+99'*EESZXXXX#v ;C*CM:::r   native_objectkwdsr   c                    d S r   r   r  r  s     r   from_nativer    s    ADr   c                    d S r   r   r  s     r   r  r        GJsr   c                    d S r   r   r  s     r   r  r    r  r   DataFrameT | LazyFrameTc                    d S r   r   r  s     r   r  r    s	     "cr   .)
eager_onlyseries_onlyIntoDataFrameT | IntoSeriesTstrictr   r  eager_or_interchange_onlyr   r  allow_series/DataFrame[IntoDataFrameT] | Series[IntoSeriesT]c                   d S r   r   r  r  r  r  r  r  s         r   r  r    	     7:cr   )r  r  c                   d S r   r   r  s         r   r  r    r  r   )r  r  r  rH   rz   c                   d S r   r   r  s         r   r  r    	     !$r   c                   d S r   r   r  s         r   r  r  +  	     	r   )r  r  r  c                   d S r   r   r  s         r   r  r  7  r  r   c                   d S r   r   r  s         r   r  r  C  r  r   )r  r  r  -IntoDataFrameT | IntoLazyFrameT | IntoSeriesTKDataFrame[IntoDataFrameT] | LazyFrame[IntoLazyFrameT] | Series[IntoSeriesT]c                   d S r   r   r  s         r   r  r  O       SVRUr   )r  r  r  c                   d S r   r   r  s         r   r  r  [  	     #r   )r  r  r  r  c                   d S r   r   r  s         r   r  r  g  r  r   rI   c                   d S r   r   r  s         r   r  r  s  r  r   c                   d S r   r   r  s         r   r  r    r  r   )r  r  r  r  Literal[True] | Nonec                   d S r   r   r  s         r   r  r    r  r   )r  r  r  r  r  c                   d S r   r   r  s         r   r  r    r  r   )r  r  r  r  c                   d S r   r   r  s         r   r  r    r  r   )r  r  r  r  IntoFrame | IntoSeries-DataFrame[Any] | LazyFrame[Any] | Series[Any]c                   d S r   r   r  s         r   r  r    	     58Cr   )r  r  r  r  c                   d S r   r   r  s         r   r  r    r  r   c                   d S r   r   r  s         r   r  r    r  r   IntoDataFrameT | IntoSeriespass_throughc                   d S r   r   r  r  r  r  r  r  s         r   r  r    r  r   c                   d S r   r   r  s         r   r  r    r  r   c                   d S r   r   r  s         r   r  r    r  r   c                   d S r   r   r  s         r   r  r    r  r   c                   d S r   r   r  s         r   r  r    r  r   c                   d S r   r   r  s         r   r  r    r  r   c                   d S r   r   r  s         r   r  r    r  r   c                   d S r   r   r  s         r   r  r  '  r  r   IntoDataFrameT | IntoLazyFrameT5DataFrame[IntoDataFrameT] | LazyFrame[IntoLazyFrameT]c                   d S r   r   r  s         r   r  r  3  s
     =@Cr   c                   d S r   r   r  s         r   r  r  ?  r  r   )r  r  r  r  c                   d S r   r   r  s         r   r  r  K  r  r   )r  r  r  r  c                   d S r   r   r  s         r   r  r  W  r  r   )r  r  r  r  c                   d S r   r   r  s         r   r  r  c  r  r   )r  r  r  r  c                   d S r   r   r  s         r   r  r  o  r  r   r  r  r  r  r  c                   d S r   r   r  s         r   r  r  {  r  r   c                   d S r   r   r  s         r   r  r    r  r   F)r  r   rJ  c                   d S r   r   r  s         r   r  r    s	     #r   )r  r  r  r  r  r  JIntoDataFrameT | IntoLazyFrameT | IntoFrame | IntoSeriesT | IntoSeries | TOLazyFrame[IntoLazyFrameT] | DataFrame[IntoDataFrameT] | Series[IntoSeriesT] | Tc          	     <   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  r  r  r  r  version)r   r   r   r(   r   nextiterr   rJ   r   r   )	r  r  r  r  r  r  r  r  r   s	            r   r  r    s    . -)Y!788  -(( k \ 25  L  V$tDzzBRBRVVnn!";!
   r   )r  narwhals_objectc                   d S r   r   r  r  s     r   	to_nativer    	     Sr   c                   d S r   r   r  s     r   r  r    r  r   c                   d S r   r   r  s     r   r  r    	     #r   c                   d S r   r   r  s     r   r  r    s    =@Sr   r  c                   d S r   r   r  r  s     r   r  r    r  r   c                   d S r   r   r  s     r   r  r    r  r   c                   d S r   r   r  s     r   r  r    r  r   c                   d S r   r   r  s     r   r  r    r|  r   )r  r  3IntoLazyFrameT | IntoDataFrameT | IntoSeriesT | Anyc               V    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  r  r  r   s       r   r  r    sL     @?????225  L <lCCCCr   TfuncCallable[..., Any] | NoneCallable[..., Any]c               b    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  r  r  ry   c                J     t                     d fd            }|S )Nargsr   r   ry   c                 @   
fd| D             } 
fd|                                 D             }fdg | |                                R D             }|                                dk    rd}t          |           	| i |}t	          |
          S )Nc           
     :    g | ]}t          |           S r  r  ).0r   r  r  r  r  r  s     r   
<listcomp>zBnarwhalify.<locals>.decorator.<locals>.wrapper.<locals>.<listcomp>  sL     
 
 
  !-).G +!-  
 
 
r   c                B    i | ]\  }}|t          |           S r  r  )r  r   valuer  r  r  r  r  s      r   
<dictcomp>zBnarwhalify.<locals>.decorator.<locals>.wrapper.<locals>.<dictcomp>%  sR     
 
 
  D% k!-).G +!-  
 
 
r   c                J    h | ]}t          |d d          x              S )__native_namespace__N)getattr)r  vbs     r   	<setcomp>zAnarwhalify.<locals>.decorator.<locals>.wrapper.<locals>.<setcomp>1  sG        $:DAAAA  r      z_Found multiple backends. Make sure that all dataframe/series inputs come from the same backend.r  )itemsr  __len__
ValueErrorr  )r  r   backendsr   r   r  r  r  r  r  r  r  s        @r   wrapperz.narwhalify.<locals>.decorator.<locals>.wrapper  s   
 
 
 
 
 
 
 
  
 
 
D
 
 
 
 
 
 
 
 $*<<>>
 
 
F   242&--//22  H !!A%%w oo%T4*6**FV,????r   )r  r   r   r   ry   r   r   )r  r  r  r  r  r  r  s   ` r   	decoratorznarwhalify.<locals>.decorator  s^    	t%	@ %	@ %	@ %	@ %	@ %	@ %	@ %	@ %	@ %	@ 
%	@N r   N)r  r  ry   r  r  )r  r  r  r  r  r  r  r  s     ````` r   
narwhalifyr    sr      34  L) ) ) ) ) ) ) ) ) )V |9T??r   c                 B    t          t          j                              S r   )r   r  r   r   r   r   r   r   G      bfhhr   namesstr | Iterable[str]c                 8    t          t          j        |            S r   )r   r  colr  s    r   r	  r	  K  s    bfen%%%r   c                 8    t          t          j        |            S r   )r   r  excluder
  s    r   r  r  O  s    bj%()))r   indicesint | Sequence[int]c                 8    t          t          j        |            S r   )r   r  nth)r  s    r   r  r  S      bfg&'''r   c                 B    t          t          j                              S r   )r   r  lenr   r   r   r  r  W  r  r   r  rd   r  r  c                F    t          t          j        | |                    S r   )r   r  lit)r  r  s     r   r  r  [  s    bfUE**+++r   columnsr   c                 8    t          t          j        |            S r   )r   r  minr  s    r   r  r  _  r  r   c                 8    t          t          j        |            S r   )r   r  maxr  s    r   r  r  c  r  r   c                 8    t          t          j        |            S r   )r   r  meanr  s    r   r  r  g  s    bgw'(((r   c                 8    t          t          j        |            S r   )r   r  medianr  s    r   r  r  k  s    bi)***r   c                 8    t          t          j        |            S r   )r   r  sumr  s    r   r!  r!  o  r  r   exprsIntoExpr | Iterable[IntoExpr]c                 8    t          t          j        |            S r   )r   r  sum_horizontalr"  s    r   r%  r%  s      b'/000r   )ignore_nullsr(  c                >    t          t          j        |d| i          S Nr(  )r   r  all_horizontalr(  r"  s     r   r+  r+  w  "     b'J\JJKKKr   c                >    t          t          j        |d| i          S r*  )r   r  any_horizontalr,  s     r   r/  r/  }  r-  r   c                 8    t          t          j        |            S r   )r   r  mean_horizontalr&  s    r   r1  r1    s    b(%0111r   c                 8    t          t          j        |            S r   )r   r  min_horizontalr&  s    r   r3  r3    r'  r   c                 8    t          t          j        |            S r   )r   r  max_horizontalr&  s    r   r5  r5    r'  r    	separatorr(  
more_exprsr`   r8  c               H    t          t          j        | g|R ||d          S )Nr7  )r   r  
concat_str)r"  r8  r(  r9  s       r   r;  r;    s5     
eYjYYILYYY  r   f_stringr  c                @    t          t          j        | g|R            S )zFormat expressions as a string.)r   r  format)r<  r  s     r   r>  r>    s"    bi04000111r   c                @    t          t          j        | g|R            S r   )r   r  coalesce)r"  r9  s     r   r@  r@    s"    bk%5*555666r   5DataFrame[Any] | LazyFrame[Any] | Series[IntoSeriesT]rx   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`)
    )r  rt  s    r   	get_levelrC    s      :r   c                  8     e Zd Zed	d            Zd
 fdZ xZS )Whenwhen	nw_f.Whenry   c                "     | |j                   S r   )
_predicate)r   rF  s     r   	from_whenzWhen.from_when  s    s4?###r   r  &IntoExpr | NonNestedLiteral | _1DArrayThenc                v    t                               t                                          |                    S r   )rL  	from_thenr   thenr   r  r   s     r   rO  z	When.then  s%    ~~eggll511222r   )rF  rG  ry   rE  )r  rK  ry   rL  )r   r   r   r   rJ  rO  r   r   s   @r   rE  rE    s[        $ $ $ [$3 3 3 3 3 3 3 3 3 3r   rE  c                  8     e Zd Zed	d            Zd
 fdZ xZS )rL  rO  	nw_f.Thenry   c                .     | |j         |j                  S r   )r;  r  )r   rO  s     r   rN  zThen.from_then  s    s4*DN;;;r   r  rK  r"   c                `    t          t                                          |                    S r   )r   r   	otherwiserP  s     r   rU  zThen.otherwise  s#    %''++E22333r   )rO  rR  ry   rL  )r  rK  ry   r"   )r   r   r   r   rN  rU  r   r   s   @r   rL  rL    s[        < < < [<4 4 4 4 4 4 4 4 4 4r   rL  
predicatesc                 N    t                               t          j        |            S r   )rE  rJ  nw_frF  )rV  s    r   rF  rF    s    >>$)Z0111r   )required)r   native_namespacer   r  r   r   rZ  ModuleType | Nonec               b    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   rZ  s        r   
new_seriesr]    s4     .88G&tVUGLLLMMMr   r   rS   c               h    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   rX  r   )r   r   rZ  s      r   r   r     s1     .88GdolGDDDEEEr   r   r   r   r   c               J    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   rX  r   r   r   r   rZ  s       r   r   r     s#     dnT67CCCDDDr   r	   r   rh   r   c               j    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   rX  r   r`  s       r   r   r     s3     .88GdodFGDDDEEEr   sourcer^   r   c               d    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   rX  read_csvrb  r   rZ  r   s       r   rd  rd    s9     .88GdmFFFGFvFFGGGr   IntoBackend[Backend] | Nonec               d    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   rX  scan_csvre  s       r   ri  ri  (  s9     )733GdmFFFGFvFFGGGr   c               d    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   rX  read_parquetre  s       r   rk  rk  :  s:     .88Gd'JJJ6JJKKKr   c               d    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`.
    rh  r   )r   r   rX  scan_parquetre  s       r   rm  rm  L  s:     )733Gd'JJJ6JJKKKr   )Sr,   r-   r.   r/   r   r0   r1   r2   r3   r4   r"   r5   r6   r7   r   r8   r9   r:   r;   r<   r   r=   r>   r&   r(   r?   r@   rA   rB   rC   rD   rE   rF   rG   r   r+  r/  r@  r	  r$   r;  r)   r*   r   r  r>  r   r   r   r  r   r   rC  rK   r   r  r  r  r5  r   r   r   r   r   r  r1  r  r  r3  r  r]  r  rd  rk  ri  rm  r+   r%   r!  r%  r  rL   rF  )rp  rq  ry   rr  )rp  rv  ry   rw  )rp  ry  ry   rz  )rp  r}  ry   r"   )rp  r  ry   r  )r  rn   r  r   ry   rn   )r  ri   r  r   ry   ri   )r  rl   r  r   ry   rl   )r  r  r  r   ry   r  )r  r  r  r   r  r   r  r   r  r   r  r   ry   r  )r  r  r  r   r  r   r  r   r  r   r  r   ry   r  )r  rH   r  r   r  r   r  r   r  r   r  rz   ry   rr  )r  rp   r  r   r  r   r  r   r  r   r  rz   ry   rp   )r  rH   r  r   r  r   r  r   r  r   r  rz   ry   rr  )r  rp   r  r   r  r   r  r   r  r   r  rz   ry   rp   )r  r  r  r   r  r   r  r   r  r   r  r   ry   r  )r  rt   r  r   r  r   r  r   r  r   r  rz   ry   rz  )r  rH   r  r   r  r   r  r   r  r   r  rz   ry   rr  )r  rI   r  r   r  r   r  r   r  r   r  rz   ry   rw  )r  rp   r  r   r  r   r  r   r  r   r  rz   ry   rp   )r  rH   r  r  r  r   r  r   r  r   r  rz   ry   rr  )r  rI   r  r  r  r   r  r   r  r   r  rz   ry   rw  )r  rH   r  r  r  r   r  r   r  r   r  rz   ry   rr  )r  r  r  r  r  r   r  r   r  r   r  r   ry   r  )r  rt   r  r  r  r   r  r   r  r   r  rz   ry   rz  )r  rH   r  r  r  r   r  r   r  r   r  rz   ry   rr  )r  r  r  r   r  r   r  r   r  r   r  r   ry   rr  )r  r  r  r   r  r   r  r   r  r   r  r   ry   r  )r  rH   r  r   r  r   r  r   r  r   r  rz   ry   rr  )r  rp   r  r   r  r   r  r   r  r   r  rz   ry   rp   )r  rH   r  r   r  r   r  r   r  r   r  rz   ry   rr  )r  rp   r  r   r  r   r  r   r  r   r  rz   ry   rp   )r  r  r  r   r  r   r  r   r  r   r  r   ry   r  )r  rt   r  r   r  r   r  r   r  r   r  rz   ry   rz  )r  r  r  r   r  r   r  r   r  r   r  rz   ry   r  )r  rp   r  r   r  r   r  r   r  r   r  rz   ry   rp   )r  rH   r  r   r  r   r  r   r  r   r  rz   ry   rr  )r  rH   r  r   r  r   r  r   r  r   r  rz   ry   rr  )r  r  r  r   r  r   r  r   r  r   r  r   ry   r  )r  rt   r  r   r  r   r  r   r  r   r  rz   ry   rz  )r  rH   r  r   r  r   r  r   r  r   r  rz   ry   rr  )r  rI   r  r   r  r   r  r   r  r   r  rz   ry   rw  )r  r   r  r   r  r   r  r   r  r   r  rJ  ry   r   )r  r  r  rJ  r  rJ  r  r   r  r   r  r   r  rJ  r  r   ry   r  )r  rr  r  r   ry   rH   )r  rw  r  r   ry   rI   )r  rz  r  r   ry   rt   )r  r   r  r   ry   r   )r  rr  r  r   ry   rH   )r  rw  r  r   ry   rI   )r  rz  r  r   ry   rt   )r  r   r  r   ry   r   )r  r  r  rJ  r  rJ  ry   r  r   )r  r  r  rJ  r  rJ  r  r   r  r   r  r   r  rJ  ry   r  )ry   r"   )r  r  ry   r"   )r  r  ry   r"   )r  rd   r  r  ry   r"   )r  r   ry   r"   )r"  r#  ry   r"   )r"  r#  r(  r   ry   r"   )
r"  r#  r9  r`   r8  r   r(  r   ry   r"   )r<  r   r  r`   ry   r"   )r"  r#  r9  r`   ry   r"   )rp  rA  ry   rx   )rV  r#  ry   rE  )r   r   r  r   r  r  r   r   rZ  r[  ry   ro   )r   rS   r   r   rZ  r[  ry   rj   )
r   r   r   r   r   r   rZ  r[  ry   rj   )
r   rh   r   r   r   r   rZ  r[  ry   rj   )
rb  r^   r   r   rZ  r[  r   r   ry   rj   )
rb  r^   r   rf  rZ  r[  r   r   ry   rm   )
__future__r   	functoolsr   typingr   r   r   r	   r
   r   r   narwhalsr  r   r   rX  narwhals._exceptionsr   narwhals._typing_compatr   r   r  r   r   r   r   r   r   r   r   r   r   r   r   narwhals.dataframer   r   r   r  r2  r    r   r"   r}  narwhals.functionsr#   r$   r%   narwhals.schemar&   ro  r   r(   r4  narwhals.stable.v1r)   r*   r+   narwhals.stable.v1.dtypesr,   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   rG   narwhals.stable.v1.typingrH   rI   narwhals.translaterJ   rK   rL   collections.abcrM   rN   rO   typesrP   typing_extensionsrQ   rR   narwhals._translaterS   narwhals._typingrT   rU   rV   rW   rX   rY   rZ   r[   r\   narwhals.dtypesr]   narwhals.typingr^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rl   rn   rp   rr   rs   rt   r   r  r  r  r   r	  r  r  r  r  r  r  r  r  r!  r%  r+  r/  r1  r3  r5  r;  r>  r@  rC  rE  rL  rF  r]  r   r   r   __annotations__r   rd  ri  rk  rm  __all__r   r   r   <module>r     s   " " " " " " "       O O O O O O O O O O O O O O O O O O     2 2 2 2 2 2 2 2 . . . . . . 9 9 9 9 9 9 9 9                            R Q Q Q Q Q Q Q 4 4 4 4 4 4 ( ( ( ( ( ( F F F F F F F F F F . . . . . . . . . . . . > > > > > > > > > >                                                           < E D D D D D D D T T T T T T T T T T %;;;;;;;;;;      11111111222222                  HGGGGGGG%%%%%%                          -=>>>J-=>>>Jgi}555GS!!!A	#AAgm<EEEA- A- A- A- A-N+ A- A- A-H8
 8
 8
 8
 8
N+ 8
 8
 8
vL
 L
 L
 L
 L
Xk" L
 L
 L
^T
 T
 T
 T
 T
6 T
 T
 T
n! ! ! ! !X ! ! ! 
 R R R 
 R	 R R R 
 R	 F F F 
 F	 ( ( ( 
 (   " 
 D D D 
 D 
 J J J 
 J 
 J J J 
 J 
" " " 
"
 

 "%"%: : : : : 
: 
 14"%: : : : : 
: 

 "%"%$ $ $ $ $ 
$ 

 "%"%     
 
 14"%$ $ $ $ $ 
$ 
 14"%     
 

 "%03"%V V V V V 
V 

 "%03     
 

 "%03"%$ $ $ $ $ 
$ 

 "%03"%$ $ $ $ $ 
$ 

 "%03"%     
 
 $'!$"%$ $ $ $ $ 
$ 
 $'!$03"%$ $ $ $ $ 
$ 
 $'03"%$ $ $ $ $ 
$ 
 $'!$03"%8 8 8 8 8 
8 
 $'!$03     
 
 $'!$03"%$ $ $ $ $ 
$ 

 "%"%$ $ $ $ $ 
$ 
 14"%: : : : : 
: 

 "%"%$ $ $ $ $ 
$ 

 "%"%     
 
 14"%$ $ $ $ $ 
$ 
 14"%     
 

 "%03"%V V V V V 
V 

 "%03     
 

 "%03"%@ @ @ @ @ 
@ 

 "%03"%     
 
 $'!$"%$ $ $ $ $ 
$ 
 $'03"%$ $ $ $ $ 
$ 
 $'!$03"%8 8 8 8 8 
8 
 $'!$03     
 
 $'!$03"%$ $ $ $ $ 
$ 
 $'!$03"%$ $ $ $ $ 
$ 
 ',     
&  $&+ $+ + + + + +\ 
KN     
 
KN     
 
EH     
 
 @ @ @ 
 @	RU     
 
RU     
 
LO     
 
 F F F 
 F  $D D D D D D. '+B  $&+ $B B B B B BJ       & & & &* * * *( ( ( (       , , , , ,( ( ( (( ( ( () ) ) )+ + + +( ( ( (1 1 1 1
 AFL L L L L L AFL L L L L L2 2 2 21 1 1 11 1 1 1 	     2 2 2 2
7 7 7 7   &3 3 3 3 349 3 3 34 4 4 4 449d 4 4 42 2 2 2 T*** #N
 15*.N N N N N +*N$ T*** 15*.	F F F F F +*F   37E 15*.E E E E E E  (
 ( ( ( ( T*** CGF 15*.F F F F F +*F" T*** 15*.	H H H H H +*H" T*** ,0*.	H H H H H +*H" T*** 15*.	L L L L L +*L" T*** ,0*.	L L L L L +*L"T T Tr   