
    [iћ                       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 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$ d d
l%m&Z'm(Z) d dl*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZF d dlGmHZH d dlImJZK d dlLmMZMmNZNmOZO d dlPmQZR d dlSmTZU d dlVmWZWmXZXmYZY d dlZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZb d dlcmdZdmeZemfZf ervd dlgmhZhmiZimjZj d dlkmlZlmmZmmnZn d dlompZpmqZqmrZrmsZsmtZtmuZumvZv d dlwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~ d dl%mZmZ d dlmZ d dlmZmZmZmZmZmZmZmZmZ  ede      Z eld      Z ed      Z G d d e'e\         Z& G d! d"e)e^         Z( G d# d$eUe`         ZT G d% d&eK      ZJ G d' d(eR      ZQedod)       Zedpd*       Zedqd+       Zedrd,       Z	 	 	 	 dsd-Zedtd.       Zedud/       Ze	 	 	 	 	 	 dvd0       Zedwd1       Ze	 	 	 	 	 	 dxd2       Ze	 	 	 	 	 	 dyd3       Ze	 	 	 	 	 	 dzd4       Ze	 	 	 	 	 	 d{d5       Ze	 	 	 	 	 	 d|d6       Ze	 	 	 	 	 	 d}d7       Zed~d8       Ze	 	 	 	 	 	 	 	 	 	 	 	 dd9       Zd:d:d:dd;	 	 	 	 	 	 	 	 	 	 	 dd<Zed=d>	 	 	 	 	 dd?       Zed=d>	 	 	 	 	 dd@       Zed=d>	 	 	 	 	 ddA       ZeddB       Zd:d>	 	 	 	 	 ddCZ	 ddDd:d:dDd;	 	 	 	 	 	 	 	 	 	 	 ddEZddFZddGZddHZddIZddJZdddKZddLZddMZddNZddOZddPZddQZddRZddSZddTZddUZddVZdWd:dX	 	 	 	 	 	 	 	 	 ddYZddZZdd[Z G d\ d]ejP                        Z G d^ d_ejR                  eJ      Zdd`Z	 d	 	 	 	 	 	 	 	 	 ddaZ	 	 	 	 	 	 ddbZ	 dddc	 	 	 	 	 	 	 dddZe&j\                  Zdeedf<   	 d	 	 	 	 	 	 	 ddgZdhdi	 	 	 	 	 	 	 	 	 ddjZdhdi	 	 	 	 	 	 	 	 	 ddkZ	 	 	 	 	 	 	 	 ddlZ	 	 	 	 	 	 	 	 ddmZg dnZy)    )annotationswraps)TYPE_CHECKINGAnyCallableFinalLiteralcastoverloadN)
exceptions	functions)issue_warning)ExprKindExprNode)TypeVarassert_never)ImplementationVersiongenerate_temporary_column_nameinherit_docis_ordered_categoricalmaybe_align_indexmaybe_convert_dtypesmaybe_get_indexmaybe_reset_indexmaybe_set_indexnot_implemented)	DataFrame	LazyFrame)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)NarwhalsUnstableWarning)Expr)_new_series_implconcatshow_versions)Schema)Series)dependenciesdtypes	selectors)
DataFrameTIntoDataFrameT	IntoFrameIntoLazyFrameT
IntoSeriesIntoSeriesT
LazyFrameTSeriesT)_from_native_implget_native_namespaceto_py_scalar)IterableMappingSequence)	ParamSpecSelfUnpack)AllowAny	AllowLazyAllowSeriesExcludeSeriesIntoArrowTable
OnlySeriesPassThroughUnknown)ArrowBackendEagerAllowedIntoBackendLazyAllowedPandasPolars)MultiColSelectorMultiIndexSelector)DType)		IntoDTypeIntoExpr
IntoSchemaNonNestedLiteralPythonLiteralSingleColSelectorSingleIndexSelector_1DArray_2DArrayT)defaultPRc                      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 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 xZS ),r   c               d    |j                   t        j                  u sJ t        |   ||       y N)level_versionr   V2super__init__selfdfry   	__class__s      l/var/www/html/userprofiledev.eatanceapp.com/venv/lib/python3.12/site-packages/narwhals/stable/v2/__init__.pyr~   zDataFrame.__init__v   +    {{gjj(((5)    c               >    t         |   ||      }t        d|      S NbackendDataFrame[Any])r}   
from_arrowr   )clsnative_framer   resultr   s       r   r   zDataFrame.from_arrow~   s'     #L'#B$f--r   Nr   c               @    t         |   |||      }t        d|      S r   )r}   	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   )r}   
from_dictsr   r   s        r   r   zDataFrame.from_dicts   )     #D&'#B$f--r   c               @    t         |   |||      }t        d|      S r   r}   
from_numpyr   r   s        r   r   zDataFrame.from_numpy   r   r   c                "    t        dt              S )Ntype[Series[Any]])r   rC   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   )r}   r   )r   r   r   s     r   r   zDataFrame.__getitem__   s     w"4((r   c                "    t         |   |      S r   )r}   
get_column)r   namer   s     r   r   zDataFrame.get_column   s     w!$''r   )sessionc               8    t        t        | 	  ||            S )N)r   r   )
_stableifyr}   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   )r}   r   )r   r   r   s     r   r   zDataFrame.to_dict   s    
 w33r   c                2    t        t        | 	               S r   )r   r}   is_duplicatedr   r   s    r   r   zDataFrame.is_duplicated   s    %'/122r   c                2    t        t        | 	               S r   )r   r}   	is_uniquer   s    r   r   zDataFrame.is_unique   s    %'+-..r   r   r   ry   &Literal['full', 'lazy', 'interchange']returnNoner   r\   r   IntoBackend[EagerAllowed]r   r   r   )r   Mapping[str, Any]r   .IntoSchema | Mapping[str, DType | None] | Noner    IntoBackend[EagerAllowed] | Noner   r   )r   zSequence[Mapping[str, Any]]r   r   r   r   r   r   r   rq   r   z3Mapping[str, DType] | Schema | Sequence[str] | Noner   r   r   r   )r   r   )r   r   )r   z-tuple[SingleIndexSelector, SingleColSelector]r   r   )r   z2str | tuple[MultiIndexSelector, SingleColSelector]r   Series[Any])r   zSingleIndexSelector | MultiIndexSelector | MultiColSelector | tuple[SingleIndexSelector, MultiColSelector] | tuple[MultiIndexSelector, MultiColSelector]r   rV   )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   LazyFrame[Any])r   z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   r   )__name__
__module____qualname__r   r|   r{   r   NwDataFramer~   classmethodr   r   r   r   propertyr   r   r   r   r   r   r   r   r   __classcell__r   s   @r   r   r   s   sa   zzH* * .).7P.	. .  BF.
 59.. ?.
 2. 
. .  BF.). ?.
 +. 
. .  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                  b     e Zd Z ee      d fd       Zedd       Z	 d	 	 	 	 	 d fdZ xZ	S )r    c               d    |j                   t        j                  u sJ t        |   ||       y rx   rz   r   s      r   r~   zLazyFrame.__init__   r   r   c                    t         S r   r   r   s    r   
_dataframezLazyFrame._dataframe       r   c                8    t        t        |   dd|i|      S )Nr   r   )r   r}   collect)r   r   kwargsr   s      r   r   zLazyFrame.collect   s!     %'/D'DVDEEr   r   r   ztype[DataFrame[Any]]r   )r   z+IntoBackend[Polars | Pandas | Arrow] | Noner   r   r   r   )
r   r   r   r   NwLazyFramer~   r   r   r   r   r   s   @r   r    r       s\    * *   FJFBFUXF	F Fr   r    c                  &    e Zd ZU ej                  Z ee      	 	 	 	 	 	 d fd       Ze	dd       Z
e	 d	 	 	 	 	 	 	 	 	 d fd       Ze	 d	 	 	 	 	 	 	 	 	 d fd       Zd fdZddddd		 	 	 	 	 	 	 	 	 d fd
Z e       Zded<   ddd fdZ xZS )rC   r   c               d    |j                   t        j                  u sJ t        |   ||       y rx   rz   )r   seriesry   r   s      r   r~   zSeries.__init__  s-     '**,,,u-r   c                    t         S r   r   r   s    r   r   zSeries._dataframe  r   r   Nc               B    t         |   ||||      }t        d|      S Nr   r   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   )r}   from_iterabler   r   s         r   r   zSeries.from_iterable   s*     &tVUG&LM6**r   c                2    t        t        | 	               S r   )r   r}   to_framer   s    r   r   zSeries.to_frame,  s    %'*,--r   Fsortparallelr   	normalizec               <    t        t        | 	  ||||            S )Nr   )r   r}   value_counts)r   r   r   r   r   r   s        r   r   zSeries.value_counts/  s-     G H49 ! 
 	
r   histignore_nullsc               H    d}t        |t               t        |   |      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   msgr   s      r   r   zSeries.any_value@  s-    # 	 	c23w l ;;r   )r   r   ry   r   r   r   r   r   )
r   r   r   rp   r   IntoDType | Noner   r   r   r   )
r   r   r   zIterable[Any]r   r   r   r   r   r   )r   r   )
r   r   r   r   r   z
str | Noner   r   r   r   )r   r   r   rm   )r   r   r   r   r|   r{   r   NwSeriesr~   r   r   r   r   r   r   r   r   r   __annotations__r   r   r   s   @r   rC   rC     sG   zzH..%K.	. .   
 #'		+	+ 	+  		+ +	+ 
	+ 	+ 
 #'		+	+ 	+  		+ +	+ 
	+ 	+. 
 
 	

 
 
 

  !D#!05 < <r   rC   c                  *    e Zd ZddddZddZddZy)	r>   Fr   c               |    d}t        |t               | j                  t        t        j
                  d|            S )Nz]`Expr.any_value` is being called from the stable API although considered an unstable feature.r   r   )r   r=   _append_noder   r   AGGREGATION)r   r   r   s      r   r   zExpr.any_valueJ  s>    # 	 	c23  X));\R
 	
r   c                T    | j                  t        t        j                  d            S )zGet the first value.firstr   r   r   ORDERABLE_AGGREGATIONr   s    r   r  z
Expr.firstT  s       (*H*H'!RSSr   c                T    | j                  t        t        j                  d            S )zGet the last value.lastr  r   s    r   r  z	Expr.lastX  s       (*H*H&!QRRr   N)r   r   r   rV   )r   rV   )r   r   r   r   r  r  r   r   r   r>   r>   I  s    05 
TSr   r>   c                  X     e Zd Zej                  Z ee      	 d	 	 	 d fd       Z xZ	S )rB   c                $    t         |   |       y r   )r}   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   r|   r{   r   NwSchemar~   r   r   s   @r   rB   rB   ]  s6    zzHQU!N!	! !r   rB   c                     y r   r   objs    r   r   r   g      ORr   c                     y r   r   r
  s    r   r   r   i  r  r   c                     y r   r   r
  s    r   r   r   k      CFr   c                     y r   r   r
  s    r   r   r   m  s    %(r   c                2   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                   S t!        |        y rx   )
isinstancer   r   _compliant_frame_with_versionr   r|   _levelr   r    r   rC   _compliant_seriesNwExprr>   _nodesr   r
  s    r   r   r   q  s     #{#--;;GJJGszzZZ#{#--;;GJJGszzZZ#x c++99'**ESZZXX#vSZZ  r   c                     y r   r   native_objectkwdss     r   from_nativer    s    PSr   c                     y r   r   r  s     r   r  r    s    QTr   c                     y r   r   r  s     r   r  r    s     r   c                     y r   r   r  s     r   r  r    s    UXr   c                     y r   r   r  s     r   r  r         !$r   c                     y r   r   r  s     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    s     7:r   c                     y r   r   r  s     r   r  r    s	     SVr   c                     y r   r   r  s     r   r  r    s    LOr   c                    y r   r   r  pass_through
eager_onlyseries_onlyallow_seriess        r   r  r    s     r   Fr,  r-  r.  r/  c          	         t        | t        t        f      r|s| S t        | t              r|s|r| S t	        | ||||dt
        j                        S )a  Convert `native_object` to Narwhals Dataframe, Lazyframe, or Series.

    Arguments:
        native_object: Raw object from user.
            Depending on the other arguments, input object can be

            - a Dataframe / Lazyframe / Series supported by Narwhals (pandas, Polars, PyArrow, ...)
            - an object which implements `__narwhals_dataframe__`, `__narwhals_lazyframe__`,
              or `__narwhals_series__`
        pass_through: Determine what happens if the object can't be converted to Narwhals

            - `False` (default): raise an error
            - `True`: pass object through as-is
        eager_only: Whether to only allow eager objects

            - `False` (default): don't require `native_object` to be eager
            - `True`: only convert to Narwhals if `native_object` is eager
        series_only: Whether to only allow Series

            - `False` (default): don't require `native_object` to be a Series
            - `True`: only convert to Narwhals if `native_object` is a Series
        allow_series: Whether to allow Series (default is only Dataframe / Lazyframe)

            - `False` or `None` (default): don't convert to Narwhals if `native_object` is a Series
            - `True`: allow `native_object` to be a Series

    Returns:
        DataFrame, LazyFrame, Series, or original object, depending
            on which combination of parameters was passed.
    F)r,  r-  r.  r/  eager_or_interchange_onlyversion)r  r   r    rC   rO   r   r|   r+  s        r   r  r    sV    X -)Y!78-(k\!!"'

 r   .r,  c                    y r   r   narwhals_objectr,  s     r   	to_nativer8         r   c                    y r   r   r6  s     r   r8  r8    r9  r   c                    y r   r   r6  s     r   r8  r8    s     r   c                    y r   r   r6  s     r   r8  r8    r  r   c               0    t        j                  | |      S )a]  Convert Narwhals object to native one.

    Arguments:
        narwhals_object: Narwhals object.
        pass_through: Determine what happens if `narwhals_object` isn't a Narwhals class

            - `False` (default): raise an error
            - `True`: pass object through as-is

    Returns:
        Object of class that user started with.
    r4  )nwr8  r6  s     r   r8  r8    s    & <<lCCr   Tc               4    dfd}| |S  ||       S )a  Decorate function so it becomes dataframe-agnostic.

    This will try to convert any dataframe/series-like object into the Narwhals
    respective DataFrame/Series, while leaving the other parameters as they are.
    Similarly, if the output of the function is a Narwhals DataFrame or Series, it will be
    converted back to the original dataframe/series type, while if the output is another
    type it will be left as is.
    By setting `pass_through=False`, then every input and every output will be required to be a
    dataframe/series-like object.

    Arguments:
        func: Function to wrap in a `from_native`-`to_native` block.
        pass_through: Determine what happens if the object can't be converted to Narwhals

            - `False`: raise an error
            - `True` (default): pass object through as-is
        eager_only: Whether to only allow eager objects

            - `False` (default): don't require `native_object` to be eager
            - `True`: only convert to Narwhals if `native_object` is eager
        series_only: Whether to only allow Series

            - `False` (default): don't require `native_object` to be a Series
            - `True`: only convert to Narwhals if `native_object` is a Series
        allow_series: Whether to allow Series (default is only Dataframe / Lazyframe)

            - `False` or `None`: don't convert to Narwhals if `native_object` is a Series
            - `True` (default): allow `native_object` to be a Series

    Returns:
        Decorated function.
    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 )Nr0  __native_namespace__   z_Found multiple backends. Make sure that all dataframe/series inputs come from the same backend.r4  )r  itemsr   getattr__len__
ValueErrorr8  )argsr   argr   valuevbbackendsr   r   r/  r-  funcr,  r.  s             r   wrapperz.narwhalify.<locals>.decorator.<locals>.wrapper=  s     	  C !-) +!-    	& $*<<>	 $2KD% k!-) +!-  $2  	 342&--/22A $:DAAAA 2   !A%w o%4*6*FV,??E		s   B;C 'C)rH  r   r   r   r   r   r   )rN  rO  r/  r-  r,  r.  s   ` r   	decoratorznarwhalify.<locals>.decorator<  s)    	t#	@ #	@ 
#	@J r   )rN  Callable[..., Any]r   rQ  r   )rN  r,  r-  r.  r/  rP  s    ```` r   
narwhalifyrR    s&    R' 'R |T?r   c                 <    t        t        j                               S )z3Instantiate an expression representing all columns.)r   r>  allr   r   r   rT  rT  k      bffhr   c                 8    t        t        j                  |        S )zCreates an expression that references one or more columns by their name(s).

    Arguments:
        names: Name(s) of the columns to use.
    )r   r>  colnamess    r   rW  rW  p  s     bffen%%r   c                 8    t        t        j                  |        S )zCreates an expression that excludes columns by their name(s).

    Arguments:
        names: Name(s) of the columns to exclude.
    )r   r>  excluderX  s    r   r[  r[  y  s     bjj%())r   c                 8    t        t        j                  |        S )a!  Creates an expression that references one or more columns by their index(es).

    Notes:
        `nth` is not supported for Polars version<1.0.0. Please use
        [`narwhals.col`][] instead.

    Arguments:
        indices: One or more indices representing the columns to retrieve.
    )r   r>  nth)indicess    r   r]  r]    s     bffg&''r   c                 <    t        t        j                               S )zReturn the number of rows.)r   r>  lenr   r   r   r`  r`    rU  r   c                @    t        t        j                  | |            S )a  Return an expression representing a literal value.

    Arguments:
        value: The value to use as literal. Can be a scalar value, list, tuple, or dict.
            Lists and tuples are converted to `List` dtype, dicts to `Struct` dtype.
        dtype: The data type of the literal value. If not provided, the data type will
            be inferred by the native library. For empty lists/dicts, dtype must be
            specified explicitly.
    )r   r>  lit)rJ  r   s     r   rb  rb    s     bffUE*++r   c                 8    t        t        j                  |        S )zReturn the minimum value.

    Note:
       Syntactic sugar for ``nw.col(columns).min()``.

    Arguments:
        columns: Name(s) of the columns to use in the aggregation function.
    )r   r>  mincolumnss    r   rd  rd         bffg&''r   c                 8    t        t        j                  |        S )zReturn the maximum value.

    Note:
       Syntactic sugar for ``nw.col(columns).max()``.

    Arguments:
        columns: Name(s) of the columns to use in the aggregation function.
    )r   r>  maxre  s    r   ri  ri    rg  r   c                 8    t        t        j                  |        S )zGet the mean value.

    Note:
        Syntactic sugar for ``nw.col(columns).mean()``

    Arguments:
        columns: Name(s) of the columns to use in the aggregation function
    )r   r>  meanre  s    r   rk  rk    s     bggw'((r   c                 8    t        t        j                  |        S )aL  Get the median value.

    Notes:
        - Syntactic sugar for ``nw.col(columns).median()``
        - Results might slightly differ across backends due to differences in the
            underlying algorithms used to compute the median.

    Arguments:
        columns: Name(s) of the columns to use in the aggregation function
    )r   r>  medianre  s    r   rm  rm    s     bii)**r   c                 8    t        t        j                  |        S )zSum all values.

    Note:
        Syntactic sugar for ``nw.col(columns).sum()``

    Arguments:
        columns: Name(s) of the columns to use in the aggregation function
    )r   r>  sumre  s    r   ro  ro    rg  r   c                 8    t        t        j                  |        S )a
  Sum all values horizontally across columns.

    Warning:
        Unlike Polars, we support horizontal sum over numeric columns only.

    Arguments:
        exprs: Name(s) of the columns to use in the aggregation function. Accepts
            expression input.
    )r   r>  sum_horizontalexprss    r   rq  rq         b''/00r   c                >    t        t        j                  |d| i      S )a  Compute the bitwise AND horizontally across columns.

    Arguments:
        exprs: Name(s) of the columns to use in the aggregation function. Accepts
            expression input.
        ignore_nulls: Whether to ignore nulls:

            - If `True`, null values are ignored. If there are no elements, the result
              is `True`.
            - If `False`, Kleene logic is followed. Note that this is not allowed for
              pandas with classical NumPy dtypes when null values are present.
    r   )r   r>  all_horizontalr   rs  s     r   rv  rv         b''J\JKKr   c                >    t        t        j                  |d| i      S )a  Compute the bitwise OR horizontally across columns.

    Arguments:
        exprs: Name(s) of the columns to use in the aggregation function. Accepts
            expression input.
        ignore_nulls: Whether to ignore nulls:

            - If `True`, null values are ignored. If there are no elements, the result
              is `False`.
            - If `False`, Kleene logic is followed. Note that this is not allowed for
              pandas with classical NumPy dtypes when null values are present.
    r   )r   r>  any_horizontalrw  s     r   rz  rz    rx  r   c                 8    t        t        j                  |        S )zCompute the mean of all values horizontally across columns.

    Arguments:
        exprs: Name(s) of the columns to use in the aggregation function. Accepts
            expression input.
    )r   r>  mean_horizontalrr  s    r   r|  r|    s     b((%011r   c                 8    t        t        j                  |        S )a  Get the minimum value horizontally across columns.

    Notes:
        We support `min_horizontal` over numeric columns only.

    Arguments:
        exprs: Name(s) of the columns to use in the aggregation function. Accepts
            expression input.
    )r   r>  min_horizontalrr  s    r   r~  r~    rt  r   c                 8    t        t        j                  |        S )a  Get the maximum value horizontally across columns.

    Notes:
        We support `max_horizontal` over numeric columns only.

    Arguments:
        exprs: Name(s) of the columns to use in the aggregation function. Accepts
            expression input.
    )r   r>  max_horizontalrr  s    r   r  r  #  rt  r    	separatorr   c               H    t        t        j                  | g|||d      S )a  Horizontally concatenate columns into a single string column.

    Arguments:
        exprs: Columns to concatenate into a single string column. Accepts expression
            input. Strings are parsed as column names, other non-expression inputs are
            parsed as literals. Non-`String` columns are cast to `String`.
        *more_exprs: Additional columns to concatenate into a single string column,
            specified as positional arguments.
        separator: String that will be used to separate the values of each column.
        ignore_nulls: Ignore null values (default is `False`).
            If set to `False`, null values will be propagated and if the row contains any
            null values, the output is null.
    r  )r   r>  
concat_str)rs  r  r   
more_exprss       r   r  r  0  s)    & 
eYjYILY r   c                @    t        t        j                  | g|       S )zFormat expressions as a string.

    Arguments:
        f_string: A string that with placeholders.
        args: Expression(s) that fill the placeholders.
    )r   r>  format)f_stringrH  s     r   r  r  H  s     bii04011r   c                @    t        t        j                  | g|       S )a  Folds the columns from left to right, keeping the first non-null value.

    Arguments:
        exprs: Columns to coalesce, must be a str, nw.Expr, or nw.Series
            where strings are parsed as column names and both nw.Expr/nw.Series
            are passed through as-is. Scalar values must be wrapped in `nw.lit`.

        *more_exprs: Additional columns to coalesce, specified as positional arguments.

    Raises:
        TypeError: If any of the inputs are not a str, nw.Expr, or nw.Series.
    )r   r>  coalesce)rs  r  s     r   r  r  R  s     bkk%5*566r   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_whenc  s    4??##r   c                H    t         j                  t        |   |            S r   )Then	from_thenr}   thenr   rJ  r   s     r   r  z	When.theng  s    ~~egl5122r   )r  z	nw_f.Whenr   r  )rJ  &IntoExpr | NonNestedLiteral | _1DArrayr   r  )r   r   r   r   r  r  r   r   s   @r   r  r  b  s    $ $3 3r   r  c                  2     e Zd Zedd       Zd fdZ xZS )r  c                      | |j                    S r   )r  )r   r  s     r   r  zThen.from_thenl  s    DKK  r   c                4    t        t        | 	  |            S r   )r   r}   	otherwiser  s     r   r  zThen.otherwisep  s    %'+E233r   )r  z	nw_f.Thenr   r  )rJ  r  r   r>   )r   r   r   r   r  r  r   r   s   @r   r  r  k  s    ! !4 4r   r  c                 L    t         j                  t        j                  |        S )a  Start a `when-then-otherwise` expression.

    Expression similar to an `if-else` statement in Python. Always initiated by a
    `pl.when(<condition>).then(<value if condition>)`, and optionally followed by a
    `.otherwise(<value if condition is false>)` can be appended at the end. If not
    appended, and the condition is not `True`, `None` will be returned.

    Info:
        Chaining multiple `.when(<condition>).then(<value>)` statements is currently
        not supported.
        See [Narwhals#668](https://github.com/narwhals-dev/narwhals/issues/668).

    Arguments:
        predicates: Condition(s) that must be met in order to apply the subsequent
            statement. Accepts one or more boolean expressions, which are implicitly
            combined with `&`. String input is parsed as a column name.

    Returns:
        A "when" object, which `.then` can be called on.
    )r  r  nw_fr  )
predicatess    r   r  r  t  s    * >>$))Z011r   c               2    t        t        | |||            S )a  Instantiate Narwhals Series from iterable (e.g. list or array).

    Arguments:
        name: Name of resulting Series.
        values: Values of make Series from.
        dtype: (Narwhals) dtype. If not provided, the native library
            may auto-infer it from `values`.
        backend: specifies which eager backend instantiate to.

            `backend` can be specified in various ways

            - As `Implementation.<BACKEND>` with `BACKEND` being `PANDAS`, `PYARROW`,
                `POLARS`, `MODIN` or `CUDF`.
            - As a string: `"pandas"`, `"pyarrow"`, `"polars"`, `"modin"` or `"cudf"`.
            - Directly as a module `pandas`, `pyarrow`, `polars`, `modin` or `cudf`.
    r   )r   r?   )r   r   r   r   s       r   
new_seriesr    s    . &tVUGLMMr   c               B    t        t        j                  | |            S )aL  Construct a DataFrame from an object which supports the PyCapsule Interface.

    Arguments:
        native_frame: Object which implements `__arrow_c_stream__`.
        backend: specifies which eager backend instantiate to.

            `backend` can be specified in various ways

            - As `Implementation.<BACKEND>` with `BACKEND` being `PANDAS`, `PYARROW`,
                `POLARS`, `MODIN` or `CUDF`.
            - As a string: `"pandas"`, `"pyarrow"`, `"polars"`, `"modin"` or `"cudf"`.
            - Directly as a module `pandas`, `pyarrow`, `polars`, `modin` or `cudf`.
    r   )r   r  r   )r   r   s     r   r   r     s      doolGDEEr   r   c               D    t        t        j                  | ||            S )aX  Instantiate DataFrame from dictionary.

    Indexes (if present, for pandas-like backends) are aligned following
    the [left-hand-rule](../concepts/pandas_index.md/).

    Notes:
        For pandas-like dataframes, conversion to schema is applied after dataframe
        creation.

    Arguments:
        data: Dictionary to create DataFrame from.
        schema: The DataFrame schema as Schema or dict of {name: type}. If not
            specified, the schema will be inferred by the native library. If
            any `dtype` is `None`, the data type for that column will be inferred
            by the native library.
        backend: specifies which eager backend instantiate to. Only
            necessary if inputs are not Narwhals Series.

            `backend` can be specified in various ways

            - As `Implementation.<BACKEND>` with `BACKEND` being `PANDAS`, `PYARROW`,
                `POLARS`, `MODIN` or `CUDF`.
            - As a string: `"pandas"`, `"pyarrow"`, `"polars"`, `"modin"` or `"cudf"`.
            - Directly as a module `pandas`, `pyarrow`, `polars`, `modin` or `cudf`.
    r   )r   r  r   r   r   r   s      r   r   r     s    > dnnT67CDDr   r	   r   c               D    t        t        j                  | ||            S )a.  Construct a DataFrame from a NumPy ndarray.

    Notes:
        Only row orientation is currently supported.

        For pandas-like dataframes, conversion to schema is applied after dataframe
        creation.

    Arguments:
        data: Two-dimensional data represented as a NumPy ndarray.
        schema: The DataFrame schema as Schema, dict of {name: type}, or a sequence of str.
        backend: specifies which eager backend instantiate to.

            `backend` can be specified in various ways

            - As `Implementation.<BACKEND>` with `BACKEND` being `PANDAS`, `PYARROW`,
                `POLARS`, `MODIN` or `CUDF`.
            - As a string: `"pandas"`, `"pyarrow"`, `"polars"`, `"modin"` or `"cudf"`.
            - Directly as a module `pandas`, `pyarrow`, `polars`, `modin` or `cudf`.
    r   )r   r  r   r  s      r   r   r     s    4 doodFGDEEr   ,)r  c               F    t        t        j                  | f||d|      S )a  Read a CSV file into a DataFrame.

    Arguments:
        source: Path to a file.
        backend: The eager backend for DataFrame creation.
            `backend` can be specified in various ways

            - As `Implementation.<BACKEND>` with `BACKEND` being `PANDAS`, `PYARROW`,
                `POLARS`, `MODIN` or `CUDF`.
            - As a string: `"pandas"`, `"pyarrow"`, `"polars"`, `"modin"` or `"cudf"`.
            - Directly as a module `pandas`, `pyarrow`, `polars`, `modin` or `cudf`.
        separator: Single byte character to use as separator in the file.
        kwargs: Extra keyword arguments which are passed to the native CSV reader.
            For example, you could use
            `nw.read_csv('file.csv', backend='pandas', engine='pyarrow')`.
    r   r  )r   r  read_csvsourcer   r  r   s       r   r  r    s)    . fMgMfM r   c               F    t        t        j                  | f||d|      S )a  Lazily read from a CSV file.

    For the libraries that do not support lazy dataframes, the function reads
    a csv file eagerly and then converts the resulting dataframe to a lazyframe.

    Arguments:
        source: Path to a file.
        backend: The eager backend for DataFrame creation.
            `backend` can be specified in various ways

            - As `Implementation.<BACKEND>` with `BACKEND` being `PANDAS`, `PYARROW`,
                `POLARS`, `MODIN` or `CUDF`.
            - As a string: `"pandas"`, `"pyarrow"`, `"polars"`, `"modin"` or `"cudf"`.
            - Directly as a module `pandas`, `pyarrow`, `polars`, `modin` or `cudf`.
        separator: Single byte character to use as separator in the file.
        kwargs: Extra keyword arguments which are passed to the native CSV reader.
            For example, you could use
            `nw.scan_csv('file.csv', backend=pd, engine='pyarrow')`.
    r  )r   r  scan_csvr  s       r   r  r    s)    , fMgMfM r   c               D    t        t        j                  | fd|i|      S )a  Read into a DataFrame from a parquet file.

    Arguments:
        source: Path to a file.
        backend: The eager backend for DataFrame creation.
            `backend` can be specified in various ways

            - As `Implementation.<BACKEND>` with `BACKEND` being `PANDAS`, `PYARROW`,
                `POLARS`, `MODIN` or `CUDF`.
            - As a string: `"pandas"`, `"pyarrow"`, `"polars"`, `"modin"` or `"cudf"`.
            - Directly as a module `pandas`, `pyarrow`, `polars`, `modin` or `cudf`.
        kwargs: Extra keyword arguments which are passed to the native parquet reader.
            For example, you could use
            `nw.read_parquet('file.parquet', backend=pd, engine='pyarrow')`.
    r   )r   r  read_parquetr  r   r   s      r   r  r  2  s$    $ d''JJ6JKKr   c               D    t        t        j                  | fd|i|      S )a  Lazily read from a parquet file.

    For the libraries that do not support lazy dataframes, the function reads
    a parquet file eagerly and then converts the resulting dataframe to a lazyframe.

    Note:
        Spark like backends require a session object to be passed in `kwargs`.

        For instance:

        ```py
        import narwhals as nw
        from sqlframe.duckdb import DuckDBSession

        nw.scan_parquet(source, backend="sqlframe", session=DuckDBSession())
        ```

    Arguments:
        source: Path to a file.
        backend: The eager backend for DataFrame creation.
            `backend` can be specified in various ways

            - As `Implementation.<BACKEND>` with `BACKEND` being `PANDAS`, `PYARROW`,
                `POLARS`, `MODIN`, `CUDF`, `PYSPARK` or `SQLFRAME`.
            - As a string: `"pandas"`, `"pyarrow"`, `"polars"`, `"modin"`, `"cudf"`,
                `"pyspark"` or `"sqlframe"`.
            - Directly as a module `pandas`, `pyarrow`, `polars`, `modin`, `cudf`,
                `pyspark.sql` or `sqlframe`.
        kwargs: Extra keyword arguments which are passed to the native parquet reader.
            For example, you could use
            `nw.scan_parquet('file.parquet', backend=pd, engine='pyarrow')`.
    r   )r   r  scan_parquetr  s      r   r  r  G  s%    F d''JJ6JKKr   )Tr!   r"   r#   r$   r   r%   r&   r'   r(   r)   r>   r*   r+   r,   r   r-   r.   r/   r0   r1   r    r2   r3   rB   rC   r4   r5   r6   r7   r8   r9   r:   r;   r<   rT  rv  rz  r  rW  r@   r  rD   rE   rE   r   r[  r  r   r   r   r  r   r   rP   r   r`  rb  ri  r  r   r   r   r   r   rk  r|  rm  rd  r~  rR  r  r]  r  r  r  r  rF   rF   rA   ro  rq  r8  rQ   r  )r  zNwDataFrame[IntoDataFrameT]r   DataFrame[IntoDataFrameT])r  zNwLazyFrame[IntoLazyFrameT]r   LazyFrame[IntoLazyFrameT])r  zNwSeries[IntoSeriesT]r   Series[IntoSeriesT])r  r  r   r>   )r  zZNwDataFrame[IntoDataFrameT] | NwLazyFrame[IntoLazyFrameT] | NwSeries[IntoSeriesT] | NwExprr   zRDataFrame[IntoDataFrameT] | LazyFrame[IntoLazyFrameT] | Series[IntoSeriesT] | Expr)r  rN   r  Unpack[OnlySeries]r   rN   )r  rN   r  Unpack[AllowSeries]r   rN   )r  rG   r  Unpack[ExcludeSeries]r   rG   )r  rM   r  Unpack[AllowLazy]r   rM   )r  rH   r  r  r   r  )r  rL   r  r  r   r  )r  rL   r  r  r   r  )r  rJ   r  r  r   r  )r  zIntoDataFrameT | IntoSeriesTr  r  r   z/DataFrame[IntoDataFrameT] | Series[IntoSeriesT])r  z-IntoDataFrameT | IntoLazyFrameT | IntoSeriesTr  zUnpack[AllowAny]r   KDataFrame[IntoDataFrameT] | LazyFrame[IntoLazyFrameT] | Series[IntoSeriesT])r  rr   r  zUnpack[PassThroughUnknown]r   rr   )r  r   r,  r   r-  r   r.  r   r/  bool | Noner   r   )r  zJIntoLazyFrameT | IntoDataFrameT | IntoSeriesT | IntoFrame | IntoSeries | Tr,  r   r-  r   r.  r   r/  r  r   zOLazyFrame[IntoLazyFrameT] | DataFrame[IntoDataFrameT] | Series[IntoSeriesT] | T)r7  r  r,  r   r   rH   )r7  r  r,  r   r   rJ   )r7  r  r,  r   r   rL   )r7  r   r,  r   r   r   )r7  r  r,  r   r   z3IntoDataFrameT | IntoLazyFrameT | IntoSeriesT | Anyr   )rN  zCallable[..., Any] | Noner,  r   r-  r   r.  r   r/  r  r   rQ  )r   r>   )rY  zstr | Iterable[str]r   r>   )r^  zint | Sequence[int]r   r>   )rJ  rl   r   r   r   r>   )rf  r   r   r>   )rs  IntoExpr | Iterable[IntoExpr]r   r>   )rs  r  r   r   r   r>   )
rs  r  r  rj   r  r   r   r   r   r>   )r  r   rH  rj   r   r>   )rs  r  r  rj   r   r>   )r  r  r   r  )
r   r   r   r   r   r   r   r   r   r   r   )r   r   r   z#Mapping[str, DType] | Schema | Noner   r   r   r   r   )
r  r   r   r   r  r   r   r   r   r   )
r  r   r   IntoBackend[Backend]r  r   r   r   r   r   )r  r   r   r   r   r   r   r   )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   narwhals._typing_compatr   r   narwhals._utilsr   r   r   r   r   r   r   r   r   r   r   narwhals.dataframer   r   r    r   narwhals.dtypesr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   narwhals.exceptionsr=   narwhals.exprr>   r  narwhals.functionsr?   r@   rA   narwhals.schemarB   r  narwhals.seriesrC   r   narwhals.stable.v2rD   rE   rF   narwhals.stable.v2.typingrG   rH   rI   rJ   rK   rL   rM   rN   narwhals.translaterO   rP   rQ   collections.abcrR   rS   rT   typing_extensionsrU   rV   rW   narwhals._translaterX   rY   rZ   r[   r\   r]   r^   narwhals._typingr_   r`   ra   rb   rc   rd   re   rf   rg   narwhals.stable.v2.dtypesrh   narwhals.typingri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rt   ru   r   r  r8  rR  rT  rW  r[  r]  r`  rb  rd  ri  rk  rm  ro  rq  rv  rz  r|  r~  r  r  r  r  r  r  r  r  r   r   r   r   r   r  r  r  r  __all__r   r   r   <module>r     sR   "  O O O  2 . ; 9    R       < 8 ( F F . . > >	 	 	 U T;;99     H/
 
 
 	S!A#AA}/N+ }/@FN+ F C<Xk" C<LS6 S(!X ! 
 R 
 R	 R 
 R	 F 
 F	 ( 
 (

 X" 
 S 
 S	 T 
 T	'< 
 
 X 
 X	$!$+@$$ 
$ 
(: 
 
(; 
 
$!$+<$$ 
$ 
:/:9L:4: 
: 
V@VJZVPV 
V 
 O 
 O	  	
   	 
   $99 9 9 9 9 U9x 
RU.AO 
 
RU.AO 
 
LO(;I 
 
 F 
 F DD
 D 9D. '+U  $U
#U U 	U
 U U Up 
&*
( 

,	(	(	)+	(
1L L 2
1
1  	(  	
 
027 3499 34499d 426 #N
NN N
 'N N4F F.GFF* 37E 15	E
E/E .	E
 ED ((
E (
 CGF
F?F '	F
 FB 	 ' 	
  : EH1>ASV6LL6LBELL*#L#L1#L=@#L#LLUr   