
    bi                       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dmd)       Zednd*       Zedod+       Zedpd,       Z	 	 	 	 dqd-Zedrd.       Zedsd/       Ze	 	 	 	 	 	 dtd0       Zedud1       Ze	 	 	 	 	 	 dvd2       Ze	 	 	 	 	 	 dwd3       Ze	 	 	 	 	 	 dxd4       Ze	 	 	 	 	 	 dyd5       Ze	 	 	 	 	 	 dzd6       Ze	 	 	 	 	 	 d{d7       Zed|d8       Ze	 	 	 	 	 	 	 	 	 	 	 	 d}d9       Zd:d:d:dd;	 	 	 	 	 	 	 	 	 	 	 d~d<Zed=d>	 	 	 	 	 dd?       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Z	 	 	 	 	 	 	 	 ddhZ	 	 	 	 	 	 	 	 ddiZ	 	 	 	 	 	 	 	 ddjZ	 	 	 	 	 	 	 	 ddkZg dl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      V/home/cdr/jupyterlab/.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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   N)r   r   r   rV   )r   r   r   r   r   r   r   r>   r>   I  s
    05 
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__X  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   U  s6    zzHQU!N!	! !r   rB   c                     y r   r   objs    r   r   r   _      ORr   c                     y r   r   r  s    r   r   r   a  r  r   c                     y r   r   r  s    r   r   r   c      CFr   c                     y r   r   r  s    r   r   r   e  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   i  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  z  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_nativer2         r   c                    y r   r   r0  s     r   r2  r2    r3  r   c                    y r   r   r0  s     r   r2  r2    s     r   c                    y r   r   r0  s     r   r2  r2    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.
    r.  )nwr2  r0  s     r   r2  r2    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 )Nr*  __native_namespace__   z_Found multiple backends. Make sure that all dataframe/series inputs come from the same backend.r.  )r  itemsr   getattr__len__
ValueErrorr2  )argsr   argr   valuevbbackendsr   r   r)  r'  funcr&  r(  s             r   wrapperz.narwhalify.<locals>.decorator.<locals>.wrapper5  s     	  !-) +!-	D 	& $*<<>	  D% k!-) +!- 	F 	 342&--/2 $:DAAAA H  !A%w o%4*6*FV,??E		s   B;C 'C)rB  r   r   r   r   r   r   )rH  rI  r)  r'  r&  r(  s   ` r   	decoratorznarwhalify.<locals>.decorator4  s)    	t#	@ #	@ 
#	@J r   )rH  Callable[..., Any]r   rK  r   )rH  r&  r'  r(  r)  rJ  s    ```` r   
narwhalifyrL    s&    R' 'R |T?r   c                 <    t        t        j                               S )z3Instantiate an expression representing all columns.)r   r8  allr   r   r   rN  rN  c      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   r8  colnamess    r   rQ  rQ  h  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   r8  excluderR  s    r   rU  rU  q  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   r8  nth)indicess    r   rW  rW  z  s     bffg&''r   c                 <    t        t        j                               S )zReturn the number of rows.)r   r8  lenr   r   r   rZ  rZ    rO  r   c                @    t        t        j                  | |            S )zReturn an expression representing a literal value.

    Arguments:
        value: The value to use as literal.
        dtype: The data type of the literal value. If not provided, the data type will
            be inferred by the native library.
    )r   r8  lit)rD  r   s     r   r\  r\    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   r8  mincolumnss    r   r^  r^         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   r8  maxr_  s    r   rc  rc    ra  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   r8  meanr_  s    r   re  re    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   r8  medianr_  s    r   rg  rg    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   r8  sumr_  s    r   ri  ri    ra  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   r8  sum_horizontalexprss    r   rk  rk         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   r8  all_horizontalr   rm  s     r   rp  rp         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   r8  any_horizontalrq  s     r   rt  rt    rr  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   r8  mean_horizontalrl  s    r   rv  rv    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   r8  min_horizontalrl  s    r   rx  rx    rn  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   r8  max_horizontalrl  s    r   rz  rz    rn  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   r8  
concat_str)rm  r}  r   
more_exprss       r   r  r  &  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   r8  format)f_stringrB  s     r   r  r  >  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   r8  coalesce)rm  r  s     r   r  r  H  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_whenY  s    4??##r   c                H    t         j                  t        |   |            S r   )Then	from_thenr}   thenr   rD  r   s     r   r  z	When.then]  s    ~~egl5122r   )r  z	nw_f.Whenr   r  )rD  &IntoExpr | NonNestedLiteral | _1DArrayr   r  )r   r   r   r   r  r  r   r   s   @r   r  r  X  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_thenb  s    DKK  r   c                4    t        t        | 	  |            S r   )r   r}   	otherwiser  s     r   r  zThen.otherwisef  s    %'+E233r   )r  z	nw_f.Thenr   r  )rD  r  r   r>   )r   r   r   r   r  r  r   r   s   @r   r  r  a  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  j  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   c               D    t        t        j                  | fd|i|      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`.
        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  read_csvsourcer   r   s      r   r  r    s"    $ dmmFFGFvFGGr   c               D    t        t        j                  | fd|i|      S )aR  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`.
        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"    * dmmFFGFvFGGr   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_parquetr  s      r   r  r    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  3  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<   rN  rp  rt  r  rQ  r@   r  rD   rE   rE   r   rU  r  r   r   r   r  r   r   rP   r   rZ  r\  rc  rz  r   r   r   r   r   re  rv  rg  r^  rx  rL  r  rW  r  r  r  r  rF   rF   rA   ri  rk  r2  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)r1  r  r&  r   r   rH   )r1  r  r&  r   r   rJ   )r1  r  r&  r   r   rL   )r1  r   r&  r   r   r   )r1  r  r&  r   r   z3IntoDataFrameT | IntoLazyFrameT | IntoSeriesT | Anyr   )rH  zCallable[..., Any] | Noner&  r   r'  r   r(  r   r)  r  r   rK  )r   r>   )rS  zstr | Iterable[str]r   r>   )rX  zint | Sequence[int]r   r>   )rD  rl   r   r   r   r>   )r`  r   r   r>   )rm  IntoExpr | Iterable[IntoExpr]r   r>   )rm  r  r   r   r   r>   )
rm  r  r  rj   r}  r   r   r   r   r>   )r  r   rB  rj   r   r>   )rm  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   zIntoBackend[Backend]r   r   r   r   )
__future__r   	functoolsr   typingr   r   r   r	   r
   r   r   narwhalsr8  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  r2  rL  rN  rQ  rU  rW  rZ  r\  r^  rc  re  rg  ri  rk  rp  rt  rv  rx  rz  r  r  r  r  r  r  r  r   r   r   r   r   r  r  r  r  __all__r   r   r   <module>r     s5   "  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	
6 	
!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:HH6HBEHH*HH1H=@HH0LL6LBELL*#L#L1#L=@#L#LLUr   