o
    $&]io                     @  st  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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-m.Z. d dl/m0Z1 d dl2m3Z3m4Z4m5Z5 d dl6m7Z8 d dl9m:Z; d dl<m=Z=m>Z>m?Z? d dl@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\ d dl]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZe d dlfmgZgmhZhmiZi erzd dljmkZkmlZlmmZm d dlnmoZo d dlpmqZqmrZrmsZs d dlmtZt d dlumvZwmxZymzZ{m|Z}m~ZmZmZmZmZmZmZmZmZmZmZ d dlmZmZmZmZmZmZmZ d dl'mZmZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZ ededZeqdZed ZG d!d" d"e)e_ Z(G d#d$ d$e+ea Z*G d%d& d&e;ec Z:G d'd( d(e1Z0G d)d* d*e8Z7edd/d0Zedd3d0Zed	d6d0Zed
d8d0Zdd;d0Zedd@dAZeddCdAZeddEdAZeddGdAZeddJdAZeddLdAZeddOdAZeddQdAZeddTdAZeddVdAZeddWdAZeddXdAZeddZdAZedd[dAZedd^dAZedd_dAZeddadAZeddbdAZeddfdAZeddhdAZed djdAZed!dldAZedmdnd"dwdAZdddmdmdmddxd#d|dAZed}d~d$ddZed}d~d%ddZed}d~d&ddZed'ddZed}dd(ddZed}dd)ddZed}dd*ddZed+ddZdddd,ddZ	d-dddmdmdmddxd.ddZd/ddZd0ddZd0ddZd1ddZd/ddZd-d2ddZd3ddZd3ddZd3ddZd3ddZd3ddZd4ddZdmdd5ddZdmdd5ddZd4ddZd4ddZd4ddĄZddmdƜd6dd˄Zd7ddτZd8ddфZd9ddՄZG ddׄ dejăZG ddل deje0ZŐd:dd܄Zeddݍ	d-dddޜd;ddZeddݍdddޜd<ddZe 	d-dddޜd=ddZe(jZded< eddݍ	d-dddޜd>ddZeddݍdddޜd?ddZeddݍdddޜd@d dZeddݍdddޜd?ddZeddݍdddޜd@ddZg dZdS (A      )annotationswraps)TYPE_CHECKINGAnyCallableFinalLiteralcastoverloadN)
exceptions	functions)issue_warning)ExprKindExprNodeis_expr)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NarwhalsUnstableWarning)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)
DataFrameTIntoDataFrameT	IntoFrameIntoLazyFrameT
IntoSeriesIntoSeriesT
LazyFrameTSeriesT)_from_native_implget_native_namespaceto_py_scalar)IterableMappingSequence)
ModuleType)	ParamSpecSelfUnpack)ExprMetadata)AllowAnyStrictV1
AllowAnyV1AllowLazyStrictV1AllowLazyV1AllowSeriesStrictV1AllowSeriesV1ExcludeSeriesStrictV1ExcludeSeriesV1IntoArrowTableOnlyEagerOrInterchangeOnlyEagerOrInterchangeStrictOnlySeriesStrictV1OnlySeriesV1PassThroughUnknownV1StrictUnknownV1)ArrowBackendEagerAllowedIntoBackendLazyAllowedPandasPolars)MultiColSelectorMultiIndexSelector)DType)

FileSource	IntoDTypeIntoExpr
IntoSchemaNonNestedLiteralPythonLiteralSingleColSelectorSingleIndexSelector_1DArray_2DArrayT)defaultPRc                      sp  e Zd ZejZeedT fddZe	dU fddZ
e		dVdddW fddZe		dVdX fddZe		dVdY fddZedZd!d"Zed[d$d%Zed\d(d)Zed]d,d)Zed^d/d)Zd_ fd2d)Zd` fd6d7Z	dVdd8da fd=d>Zed?d@dbdDdEZedcdHdEZedId@dddLdEZdId@dd fdMdEZde fdNdOZde fdPdQZdfdRdSZ  ZS )gr    dfr   level&Literal['full', 'lazy', 'interchange']returnNonec                  $   |j tju sJ t j||d d S N)r   _versionr   V1super__init__selfr   r   	__class__ Y/var/www/html/IGF-ODF-V3/venv/lib/python3.10/site-packages/narwhals/stable/v1/__init__.pyr         zDataFrame.__init__native_framerd   backendIntoBackend[EagerAllowed]DataFrame[Any]c                  s   t  j||d}td|S Nr   r   )r   
from_arrowr
   )clsr   r   resultr   r   r   r      s   
zDataFrame.from_arrowNr   dataMapping[str, Any]schema.IntoSchema | Mapping[str, DType | None] | None IntoBackend[EagerAllowed] | Nonec                     t  j|||d}td|S r   )r   	from_dictr
   r   r   r   r   r   r   r   r   r         
zDataFrame.from_dictSequence[Any]c                  r   r   )r   
from_dictsr
   r   r   r   r   r      r   zDataFrame.from_dictsr~   3Mapping[str, DType] | Schema | Sequence[str] | Nonec                  r   r   r   
from_numpyr
   r   r   r   r   r      r   zDataFrame.from_numpytype[Series[Any]]c                 C  
   t dtS )Nr   )r
   r)   r   r   r   r   _series      
zDataFrame._seriestype[LazyFrame[Any]]c                 C  r   )Nr   )r
   r!   r   r   r   r   
_lazyframe   r   zDataFrame._lazyframeitem-tuple[SingleIndexSelector, SingleColSelector]c                 C     d S Nr   r   r   r   r   r   __getitem__      zDataFrame.__getitem__2str | tuple[MultiIndexSelector, SingleColSelector]Series[Any]c                 C  r   r   r   r   r   r   r   r         SingleIndexSelector | MultiIndexSelector | MultiColSelector | tuple[SingleIndexSelector, MultiColSelector] | tuple[MultiIndexSelector, MultiColSelector]rY   c                 C  r   r   r   r   r   r   r   r      s   
  SingleIndexSelector | SingleColSelector | MultiColSelector | MultiIndexSelector | tuple[SingleIndexSelector, SingleColSelector] | tuple[SingleIndexSelector, MultiColSelector] | tuple[MultiIndexSelector, SingleColSelector] | tuple[MultiIndexSelector, MultiColSelector]Series[Any] | Self | Anyc                      t  |S r   )r   r   r   r   r   r   r      s   namestrr)   c                   r   r   )r   
get_column)r   r   r   r   r   r      s   zDataFrame.get_column)sessionIntoBackend[LazyAllowed] | Noner   
Any | NoneLazyFrame[Any]c                  s   t t j||dS )N)r   r   )
_stableifyr   lazy)r   r   r   r   r   r   r      s   zDataFrame.lazy.	as_seriesr   Literal[True]dict[str, Series[Any]]c                C  r   r   r   r   r   r   r   r   to_dict   r   zDataFrame.to_dictLiteral[False]dict[str, list[Any]]c                C  r   r   r   r   r   r   r   r      r   Tbool-dict[str, Series[Any]] | dict[str, list[Any]]c                C  r   r   r   r   r   r   r   r      r   c                  s   t  j|dS )Nr   )r   r   r   r   r   r   r      s   c                      t t  S r   )r   r   is_duplicatedr   r   r   r   r         zDataFrame.is_duplicatedc                   r   r   )r   r   	is_uniquer   r   r   r   r      r   zDataFrame.is_uniquec                 C     |  t  S r   selectall_l1_normr   r   r   r   r         zDataFrame._l1_normr   r   r   r   r   r   )r   rd   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   )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   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   rY   )__name__
__module____qualname__r   r   r   r   NwDataFramer   classmethodr   r   r   r   propertyr   r   r   r   r   r   r   r   r   r   __classcell__r   r   r   r   r       sZ    



r    c                      s   e Zd Zeed+ fddZed,d
dZd-ddZ	d.d/ fddZ	d0ddZ
d1d2 fddZd3d4d!d"Z	#d5dd$d6d)d*Z  ZS )7r!   r   r   r   r   r   r   c                  r   r   r   r   r   r   r   r     r   zLazyFrame.__init__type[DataFrame[Any]]c                 C     t S r   r    r   r   r   r   
_dataframe
     zLazyFrame._dataframemetadatar[   c                 C  r   r   r   )r   r   r   r   r   _validate_metadata  r   zLazyFrame._validate_metadataNr   +IntoBackend[Polars | Pandas | Arrow] | Nonekwargsr   c                   s   t t jdd|i|S )Nr   r   )r   r   collect)r   r   r   r   r   r   r     s   zLazyFrame.collectrY   c                 C  r   r   r   r   r   r   r   r     r   zLazyFrame._l1_norm   nintc                   r   )Get the last `n` rows.)r   tailr   r   r   r   r   r     s   zLazyFrame.tailr   offsetc                 C  s   |  | jj||d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   r   r   r   r     s   zLazyFrame.gather_everyindex)order_byr   r   r   str | Sequence[str] | Nonec                C  s*   t |tr|gn|}| | jj||dS )N)r   r   )
isinstancer   r   r   with_row_index)r   r   r   	order_by_r   r   r   r  *  s   zLazyFrame.with_row_indexr   r   r   )r   r[   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   rY   r   r   r   r   r   r   rY   )r   )r   r   r   r   r   rY   )r   r   r   r   NwLazyFramer   r   r   r   r   r   r   r   r  r   r   r   r   r   r!     s    

r!   c                      s   e Zd ZejZeed5 fddZe			d6d7 fddZ
e			d6d8 fddZed9ddZd: fddZddd	ddd; fd%d&Z		d6d	d'd(d< fd.d/Zdd0d= fd3d4Z  ZS )>r)   seriesr   r   r   r   r   c                  r   r   r   )r   r	  r   r   r   r   r   9  s   zSeries.__init__Nr   r   valuesr}   dtypeIntoDType | Noner   r   r   c                     t  j||||d}td|S Nr   r   r   r   r   r
  r  r   r   r   r   r   r   C     	
zSeries.from_numpyIterable[Any]c                  r  r  )r   from_iterabler
   r  r   r   r   r  O  r  zSeries.from_iterabler   c                 C  r   r   r   r   r   r   r   r   [  r   zSeries._dataframer   c                   r   r   )r   r   to_framer   r   r   r   r  _  r   zSeries.to_frameFsortparallelr   	normalizer  r   r  
str | Noner  c                  s   t t j||||dS )Nr  )r   r   value_counts)r   r  r  r   r  r   r   r   r  b  s
   zSeries.value_countsT)	bin_countinclude_breakpointbinslist[float] | Noner  
int | Noner  c                  s$   d}t |t tt j|||dS )NzZ`Series.hist` is being called from the stable API although considered an unstable feature.)r  r  r  )r   r#   r   r   hist)r   r  r  r  msgr   r   r   r  p  s   
zSeries.histignore_nullsr"  rz   c                  s   d}t |t t j|dS )Nz_`Series.any_value` is being called from the stable API although considered an unstable feature.r!  )r   r#   r   	any_valuer   r"  r   r   r   r   r#    s   
zSeries.any_value)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  r   r   r  r  r   r   r   )r  r  r  r  r  r   r   r   )r"  r   r   rz   )r   r   r   r   r   r   r   NwSeriesr   r   r   r  r   r   r  r  r  r#  r   r   r   r   r   r)   6  s0    	r)   c                      s   e Zd Zd/ fddZd0d1dd	Zd0d1d
dZd2d3ddZddd4ddZdddd5ddZd/ddZ	d/dd Z
d/d!d"Z	d6dddd#d7d)d*Zdd+d8d-d.Z  ZS )9r$   r   rY   c                   s
   t   S r   )r   _taxicab_normr   r   r   r   r     s   
zExpr._l1_norm
   r   r   c                 C     |  ttjd|dS )zGet the first `n` rows.headr   _append_noder   r   ORDERABLE_FILTRATIONr   r   r   r   r)       z	Expr.headc                 C  r(  )r   r   r*  r+  r   r   r   r   r     r.  z	Expr.tailr   r   c                 C     |  ttjd||dS )zTake every nth value in the Series and return as new Series.

        Arguments:
            n: Gather every *n*-th row.
            offset: Starting index.
        r   r   r+  r   r   r   r   r     s   zExpr.gather_everyN)maintain_orderr0  bool | Nonec                C  s(   |durd}t |t | ttj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.unique)r   UserWarningr,  r   r   
FILTRATION)r   r0  r   r   r   r   r2    s
   
zExpr.uniqueF
descending
nulls_lastr6  r   r7  c                C  r/  )z*Sort this column. Place null values first.r  r5  )r,  r   r   WINDOW)r   r6  r7  r   r   r   r    s
   
z	Expr.sortc                 C     |  ttjdS )z'Returns the index of the maximum value.arg_maxr,  r   r   ORDERABLE_AGGREGATIONr   r   r   r   r:       zExpr.arg_maxc                 C  r9  )z'Returns the index of the minimum value.arg_minr;  r   r   r   r   r>    r=  zExpr.arg_minc                 C  r9  )z/Find elements where boolean expression is True.arg_truer+  r   r   r   r   r?    r=  zExpr.arg_true)fractionwith_replacementseedr  r@  float | NonerA  rB  c             
   C  s   |  ttjd||||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.
        sample)r   r@  rA  rB  )r,  r   r   r4  )r   r   r@  rA  rB  r   r   r   rD    s   zExpr.sampler!  r"  c                C  s$   d}t |t | ttjd|dS )Nz]`Expr.any_value` is being called from the stable API although considered an unstable feature.r#  r!  )r   r#   r,  r   r   AGGREGATIONr$  r   r   r   r#    s   
zExpr.any_valuer   )r'  r  r  r  )r0  r1  r   rY   )r6  r   r7  r   r   rY   r   )
r   r  r@  rC  rA  r   rB  r  r   rY   )r"  r   r   rY   )r   r   r   r   r)  r   r   r2  r  r:  r>  r?  rD  r#  r   r   r   r   r   r$     s"    



r$   c                      s0   e Zd ZejZee	dd	 fddZ  Z	S )
r(   Nr   8Mapping[str, DType] | Iterable[tuple[str, DType]] | Noner   r   c                   s   t  | d S r   )r   r   )r   r   r   r   r   r     s   zSchema.__init__r   )r   rF  r   r   )
r   r   r   r   r   r   r   NwSchemar   r   r   r   r   r   r(     s
    r(   objNwDataFrame[IntoDataFrameT]r   DataFrame[IntoDataFrameT]c                 C  r   r   r   rH  r   r   r   r     r   r   NwLazyFrame[IntoLazyFrameT]LazyFrame[IntoLazyFrameT]c                 C  r   r   r   rK  r   r   r   r     r   NwSeries[IntoSeriesT]Series[IntoSeriesT]c                 C  r   r   r   rK  r   r   r   r     r   NwExprc                 C  r   r   r   rK  r   r   r   r     r   ZNwDataFrame[IntoDataFrameT] | NwLazyFrame[IntoLazyFrameT] | NwSeries[IntoSeriesT] | NwExprRDataFrame[IntoDataFrameT] | LazyFrame[IntoLazyFrameT] | Series[IntoSeriesT] | Exprc                 C  s   t | trt| jtj| jdS t | tr"t	| jtj| jdS t | t
r3t| jtj| jdS t | tr=t| j S t|  d S r   )r  r   r    r   _with_versionr   r   _levelr  r!   r%  r)   _compliant_seriesrP  r$   _nodesr   rK  r   r   r   r     s   




native_objectrP   kwdsUnpack[OnlySeries]c                 K  r   r   r   rW  rX  r   r   r   from_native  r   r[  Unpack[OnlySeriesStrict]c                 K  r   r   r   rZ  r   r   r   r[    r   Unpack[AllowSeries]c                 K  r   r   r   rZ  r   r   r   r[    r   Unpack[AllowSeriesStrict]c                 K  r   r   r   rZ  r   r   r   r[    r   rI   Unpack[ExcludeSeries]c                 K  r   r   r   rZ  r   r   r   r[    r   Unpack[ExcludeSeriesStrict]c                 K  r   r   r   rZ  r   r   r   r[    r   rO   Unpack[AllowLazy]c                 K  r   r   r   rZ  r   r   r   r[    r   Unpack[AllowLazyStrict]c                 K  r   r   r   rZ  r   r   r   r[    r   rJ   Unpack[OnlyEagerOrInterchange]c                 K  r   r   r   rZ  r   r   r   r[  "  r   $Unpack[OnlyEagerOrInterchangeStrict]c                 K  r   r   r   rZ  r   r   r   r[  &  r   c                 K  r   r   r   rZ  r   r   r   r[  *  r   c                 K  r   r   r   rZ  r   r   r   r[  .  r   rN   c                 K  r   r   r   rZ  r   r   r   r[  2  r   c                 K  r   r   r   rZ  r   r   r   r[  6  r   IntoDataFrameT | IntoSeriesT/DataFrame[IntoDataFrameT] | Series[IntoSeriesT]c                 K  r   r   r   rZ  r   r   r   r[  :  r   c                 K  r   r   r   rZ  r   r   r   r[  >  r   rL   c                 K  r   r   r   rZ  r   r   r   r[  B  r   c                 K  r   r   r   rZ  r   r   r   r[  F  r   -IntoDataFrameT | IntoLazyFrameT | IntoSeriesTUnpack[AllowAny]KDataFrame[IntoDataFrameT] | LazyFrame[IntoLazyFrameT] | Series[IntoSeriesT]c                 K  r   r   r   rZ  r   r   r   r[  J  r   Unpack[AllowAnyStrict]c                 K  r   r   r   rZ  r   r   r   r[  N  s   Unpack[PassThroughUnknown]c                 K  r   r   r   rZ  r   r   r   r[  S  r   Unpack[StrictUnknown]c                 K  r   r   r   rZ  r   r   r   r[  U  r   F)eager_or_interchange_onlyr   pass_throughr   
eager_onlyrm  series_onlyallow_seriesr1  c                C  r   r   r   )rW  rn  ro  rm  rp  rq  r   r   r   r[  Z  s   	)strictrn  ro  rm  rp  rq  JIntoDataFrameT | IntoLazyFrameT | IntoFrame | IntoSeriesT | IntoSeries | Trr  OLazyFrame[IntoLazyFrameT] | DataFrame[IntoDataFrameT] | Series[IntoSeriesT] | Tc          	   	   K  sp   t | ttfr|s| S t | tr|s|r| S t||dd}|r,dtt|}t|t| |||||t	j
d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 )rn  ro  rm  rp  rq  version)r  r    r!   r)   r   nextiter	TypeErrorrQ   r   r   )	rW  rr  rn  ro  rm  rp  rq  rX  r   r   r   r   r[  f  s&   .)rr  narwhals_objectr   c                C  r   r   r   r{  rr  r   r   r   	to_native  r   r}  c                C  r   r   r   r|  r   r   r   r}    r   c                C  r   r   r   r|  r   r   r   r}    r   c                C  r   r   r   r|  r   r   r   r}    r   rn  r   c                C  r   r   r   r{  rn  r   r   r   r}    r   c                C  r   r   r   r  r   r   r   r}    r   c                C  r   r   r   r  r   r   r   r}    r   c                C  r   r   r   r  r   r   r   r}    r   )rr  rn  3IntoLazyFrameT | IntoDataFrameT | IntoSeriesT | Anyc                C  s(   ddl m} |||dd}tj| |d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   Fru  r~  )narwhals._utilsr   nwr}  )r{  rr  rn  r   r   r   r   r}    s
   TfuncCallable[..., Any] | NoneCallable[..., Any]c                  s8   t |ddd	 fdd}| du r|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`.
    Tru  r  r  r   c                   s$   t  d fdd}|S )Nargsr   r   r   c                    s   fdd| D } fdd|  D } fddg | | R D }| dkr8d}t|| i |}t|d	S )
Nc              
     s    g | ]}t | d qS )rn  ro  rm  rp  rq  r[  ).0argrq  ro  rm  rn  rp  r   r   
<listcomp>  s    	zBnarwhalify.<locals>.decorator.<locals>.wrapper.<locals>.<listcomp>c                   s&   i | ]\}}|t | d qS r  r  )r  r   valuer  r   r   
<dictcomp>  s    	zBnarwhalify.<locals>.decorator.<locals>.wrapper.<locals>.<dictcomp>c                   s"   h | ]}t |d d  r  qS )__native_namespace__N)getattr)r  vbr   r   	<setcomp>  s    zAnarwhalify.<locals>.decorator.<locals>.wrapper.<locals>.<setcomp>   z_Found multiple backends. Make sure that all dataframe/series inputs come from the same backend.r~  )itemsr
  __len__
ValueErrorr}  )r  r   backendsr   r   )rq  ro  rm  r  rn  rp  r  r   wrapper  s   		
z.narwhalify.<locals>.decorator.<locals>.wrapper)r  r   r   r   r   r   r   )r  r  r  )r  r   	decorator  s   'znarwhalify.<locals>.decoratorN)r  r  r   r  r  )r  rr  rn  ro  rm  rp  rq  r  r   r  r   
narwhalify  s   +r  c                   C     t t S r   )r   r  r   r   r   r   r   r        r   namesstr | Iterable[str]c                  G     t tj|  S r   )r   r  colr  r   r   r   r    r   r  c                  G  r  r   )r   r  excluder  r   r   r   r    r   r  indicesint | Sequence[int]c                  G  r  r   )r   r  nth)r  r   r   r   r    r   r  c                   C  r  r   )r   r  lenr   r   r   r   r    r  r  r  ry   r  r  c                 C  s   t t| |S r   )r   r  lit)r  r  r   r   r   r  !     r  columnsr   c                  G  r  r   )r   r  minr  r   r   r   r  %  r   r  c                  G  r  r   )r   r  maxr  r   r   r   r  )  r   r  c                  G  r  r   )r   r  meanr  r   r   r   r  -  r   r  c                  G  r  r   )r   r  medianr  r   r   r   r  1  r   r  c                  G  r  r   )r   r  sumr  r   r   r   r  5  r   r  exprsIntoExpr | Iterable[IntoExpr]c                  G  r  r   )r   r  sum_horizontalr  r   r   r   r  9  r   r  r!  r"  c                 G     t tj|d| iS Nr"  )r   r  all_horizontalr"  r  r   r   r   r  =     r  c                 G  r  r  )r   r  any_horizontalr  r   r   r   r  C  r  r  c                  G  r  r   )r   r  mean_horizontalr  r   r   r   r  I  r   r  c                  G  r  r   )r   r  min_horizontalr  r   r   r   r  M  r   r  c                  G  r  r   )r   r  max_horizontalr  r   r   r   r  Q  r   r   	separatorr"  
more_exprsrw   r  c                G  s   t tj| g|R ||dS )Nr  )r   r  
concat_str)r  r  r"  r  r   r   r   r  U  s   r  f_stringr  c                 G     t tj| g|R  S )zFormat expressions as a string.)r   r  format)r  r  r   r   r   r  `  r.  r  c                 G  r  r   )r   r  coalesce)r  r  r   r   r   r  e  s   r  5DataFrame[Any] | LazyFrame[Any] | Series[IntoSeriesT]r   c                 C  s   | 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`)
    )rT  rK  r   r   r   	get_leveli  s   r  c                      ,   e Zd ZedddZd fd	d
Z  ZS )Whenwhen	nw_f.Whenr   c                 C  s
   | |j S r   )
_predicate)r   r  r   r   r   	from_when}  r   zWhen.from_whenr  &IntoExpr | NonNestedLiteral | _1DArrayThenc                   s   t t |S r   )r  	from_thenr   thenr   r  r   r   r   r    s   z	When.then)r  r  r   r  )r  r  r   r  )r   r   r   r   r  r  r   r   r   r   r   r  |      r  c                      r  )r  r  	nw_f.Thenr   c                 C  s
   | |j  S r   )rV  )r   r  r   r   r   r    r   zThen.from_thenr  r  r$   c                   s   t t |S r   )r   r   	otherwiser  r   r   r   r    r  zThen.otherwise)r  r  r   r  )r  r  r   r$   )r   r   r   r   r  r  r   r   r   r   r   r    r  r  
predicatesc                  G  s   t tj|  S r   )r  r  nw_fr  )r  r   r   r   r    r  r  )required)r   native_namespacer   r
  r   r   r  ModuleType | Noner   c                C  s   t d|}tt| |||d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  r   r   r   
new_series  s   
r  r   rd   r   c                C  s   t d|}ttj| |d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  r   r   r   r     s   
r   r   r   r   #Mapping[str, DType] | Schema | Nonec                C  s   t tj| ||d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  r   r   r   r     s   r   r   r   r~   r   c                C  s   t d|}ttj| ||d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  r   r   r   r     s   
r   sourceru   r   c                K  $   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r  r   r  r   r   r   r   r       
r  IntoBackend[Backend] | Noner   c                K  r  )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  r   r   r   r    r  r  c                K  r  )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  r   r   r   r     r  r  c                K  r  )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  r   r   r   r    r  r  )Ur-   r.   r/   r0   r    r1   r2   r3   r4   r5   r$   r6   r7   r8   r   r9   r:   r;   r<   r=   r"   r!   r>   r?   r(   r)   r@   rA   rB   rC   rD   rE   rF   rG   rH   r   r  r  r  r  r&   r  r*   r+   r   r  r  r   r   r   r[  r   r   r  rR   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}  rS   r  )rH  rI  r   rJ  )rH  rL  r   rM  )rH  rN  r   rO  )rH  rP  r   r$   )rH  rQ  r   rR  )rW  rP   rX  rY  r   rP   )rW  rP   rX  r\  r   rP   )rW  rP   rX  r]  r   rP   )rW  rP   rX  r^  r   rP   )rW  rI   rX  r_  r   rI   )rW  rI   rX  r`  r   rI   )rW  rO   rX  ra  r   rO   )rW  rO   rX  rb  r   rO   )rW  rJ   rX  rc  r   rJ  )rW  rJ   rX  rd  r   rJ  )rW  rJ   rX  r_  r   rJ  )rW  rJ   rX  r`  r   rJ  )rW  rN   rX  rY  r   rO  )rW  rN   rX  r\  r   rO  )rW  re  rX  r]  r   rf  )rW  re  rX  r^  r   rf  )rW  rL   rX  ra  r   rM  )rW  rL   rX  rb  r   rM  )rW  rg  rX  rh  r   ri  )rW  rg  rX  rj  r   ri  )rW  r   rX  rk  r   r   )rW  r   rX  rl  r   r   )rW  r   rn  r   ro  r   rm  r   rp  r   rq  r1  r   r   )rW  rs  rr  r1  rn  r1  ro  r   rm  r   rp  r   rq  r1  rX  r   r   rt  )r{  rJ  rr  r   r   rJ   )r{  rM  rr  r   r   rL   )r{  rO  rr  r   r   rN   )r{  r   rr  r   r   r   )r{  rJ  rn  r   r   rJ   )r{  rM  rn  r   r   rL   )r{  rO  rn  r   r   rN   )r{  r   rn  r   r   r   )r{  ri  rr  r1  rn  r1  r   r  r   )r  r  rr  r1  rn  r1  ro  r   rm  r   rp  r   rq  r1  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  r  r"  r   r   r$   )
r  r  r  rw   r  r   r"  r   r   r$   )r  r   r  rw   r   r$   )r  r  r  rw   r   r$   )rH  r  r   r   )r  r  r   r  )r   r   r
  r   r  r  r   r   r  r  r   r   )r   rd   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  ru   r   r   r  r  r   r   r   r   )
r  ru   r   r  r  r  r   r   r   r   )
__future__r   	functoolsr   typingr   r   r   r   r	   r
   r   narwhalsr  r   r   r  narwhals._exceptionsr   narwhals._expression_parsingr   r   r   narwhals._typing_compatr   r   r  r   r   r   r   r   r   r   r   r   r   r   r   narwhals.dataframer    r   r!   r  narwhals.exceptionsr"   r#   narwhals.exprr$   rP  narwhals.functionsr%   r&   r'   narwhals.schemar(   rG  narwhals.seriesr)   r%  narwhals.stable.v1r*   r+   r,   narwhals.stable.v1.dtypesr-   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   rH   narwhals.stable.v1.typingrI   rJ   rK   rL   rM   rN   rO   rP   narwhals.translaterQ   rR   rS   collections.abcrT   rU   rV   typesrW   typing_extensionsrX   rY   rZ   r[   narwhals._translater\   AllowAnyStrictr]   AllowAnyr^   AllowLazyStrictr_   	AllowLazyr`   AllowSeriesStrictra   AllowSeriesrb   ExcludeSeriesStrictrc   ExcludeSeriesrd   re   rf   rg   OnlySeriesStrictrh   
OnlySeriesri   PassThroughUnknownrj   StrictUnknownnarwhals._typingrk   rl   rm   rn   ro   rp   rq   rr   rs   narwhals.dtypesrt   narwhals.typingru   rv   rw   rx   ry   rz   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  r  r  r  r   r   r   __annotations__r   r  r  r  r  __all__r   r   r   r   <module>   s   $8x(
D$	0 2U\
.E		