
    Wh                    2	   d dl mZ d dlmZ d dlmZmZmZmZm	Z	m
Z
 d dlZd dlmZmZ d dlmZ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)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@ d d
lAmBZC d dlDmEZEmFZFmGZG d dlHmIZJ d dlKmLZM d dlNmOZOmPZPmQZQ d dlRmSZSmTZTmUZU d dlVmWZWmXZX erd dlYmZZZm[Z[m\Z\ d dl]m^Z^m_Z_ d dl`maZa d dlbmcZcmdZdmeZemfZfmgZgmhZhmiZi d dlmjZjmkZk d dl$mlZl d dlVmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZu  edd      Zv edd      Zw edd      Zx ede       Zy e^d!      Zz ed"      Z{ ed#d$e%      Z| G d& d'e!eW         Z  G d( d)e#eX         Z" G d* d+eMe|         ZL G d, d-eC      ZB G d. d/eJ      ZIe
d~d0       Z}e
dd1       Z}e
dd2       Z}e
dd3       Z}	 	 	 	 dd4Z}e
dd5       Z~e
dd6       Z~e
dd7       Z~e
	 	 	 	 	 	 dd8       Z~e
d9d9d:	 	 	 	 	 	 	 	 	 	 	 dd;       Z~e
d9d<	 	 	 	 	 	 	 	 	 	 	 dd=       Z~e
d9d9d9d>	 	 	 	 	 	 	 	 	 	 	 dd?       Z~e
d9d9d9d>	 	 	 	 	 	 	 	 	 	 	 dd@       Z~e
d9d9dA	 	 	 	 	 	 	 	 	 	 	 ddB       Z~e
d9d9dA	 	 	 	 	 	 	 	 	 	 	 ddC       Z~e
d9d9dD	 	 	 	 	 	 	 	 	 	 	 ddE       Z~e
d9d9d9d9dF	 	 	 	 	 	 	 	 	 	 	 ddG       Z~e
d9d9d9d9dF	 	 	 	 	 	 	 	 	 	 	 ddH       Z~e
d9d9d9dI	 	 	 	 	 	 	 	 	 	 	 ddJ       Z~e
d9d9d9dK	 	 	 	 	 	 	 	 	 	 	 ddL       Z~e
d9d9d9dM	 	 	 	 	 	 	 	 	 	 	 ddN       Z~e
	 	 	 	 	 	 	 	 	 	 	 	 ddO       Z~dPdPdPddF	 	 	 	 	 	 	 	 	 	 	 	 	 ddQZ~e
d9dR	 	 	 	 	 ddS       Ze
d9dR	 	 	 	 	 ddT       Ze
d9dR	 	 	 	 	 ddU       Ze
ddV       ZdPdR	 	 	 	 	 ddWZ	 ddXdPdPdXdF	 	 	 	 	 	 	 	 	 	 	 ddYZddZZdd[Zdd\Zdd]Zdd^Zddd_Zdd`ZddaZddbZddcZdddZddeZddfZddgZddhZddiZddjZdkdPdl	 	 	 	 	 	 	 	 	 ddmZddnZ G do dpej(                        Z G dq drej*                  eB      ZddsZ	 d	 	 	 	 	 	 	 	 	 ddtZ	 	 	 	 	 	 dduZ	 dddv	 	 	 	 	 	 	 ddwZ	 d	 	 	 	 	 	 	 ddxZ	 	 	 	 	 	 	 	 ddyZ	 	 	 	 	 	 	 	 ddzZ	 	 	 	 	 	 	 	 dd{Z	 	 	 	 	 	 	 	 dd|Zg d}Zy)    )annotationswraps)TYPE_CHECKINGAnyCallableLiteralcastoverloadN)
exceptions	functions)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)Expr)_new_series_implconcatshow_versions)Schema)Series)dependenciesdtypes	selectors)_from_native_implget_native_namespaceto_py_scalar)IntoDataFrameTIntoLazyFrameT)IterableMappingSequence)	ParamSpecSelf)IntoArrowTable)ArrowBackendEagerAllowedIntoBackendLazyAllowedPandasPolars)MultiColSelectorMultiIndexSelector)DType)		IntoDTypeIntoExpr	IntoFrame
IntoSeriesNonNestedLiteralSingleColSelectorSingleIndexSelector_1DArray_2DArray
DataFrameTDataFrame[Any])bound
LazyFrameTLazyFrame[Any]SeriesTSeries[Any]T)defaultPRIntoSeriesTrZ   )rb   rh   c                      e Zd Zej                  Z ee      d fd       Ze		 	 	 	 	 	 d fd       Z
e		 ddd	 	 	 	 	 	 	 d fd       Ze		 d	 	 	 	 	 	 	 d fd       Zedd       Zedd       Zed d	       Ze	 	 	 	 d!d
       Ze	 	 	 	 d"d       Z	 	 	 	 d# fdZd$ fdZ	 ddd	 	 	 	 	 d% fdZeddd&d       Zed'd       Zedd	 	 	 d(d       Zdd	 	 	 d( fdZd) fdZd) fdZ xZS )*r   c               d    |j                   t        j                  u sJ t        |   ||       y N)level_versionr   V2super__init__selfdfro   	__class__s      U/var/www/html/jupyter_env/lib/python3.12/site-packages/narwhals/stable/v2/__init__.pyrt   zDataFrame.__init__g   +    {{gjj(((5)    c               >    t         |   ||      }t        d|      S Nbackendra   )rs   
from_arrowr
   )clsnative_framer   resultrx   s       ry   r   zDataFrame.from_arrowo   s'     #L'#B$f--r{   Nr~   c               @    t         |   |||      }t        d|      S r}   )rs   	from_dictr
   r   dataschemar   r   rx   s        ry   r   zDataFrame.from_dictv   s)     "4"A$f--r{   c               @    t         |   |||      }t        d|      S r}   rs   
from_numpyr
   r   s        ry   r   zDataFrame.from_numpy   s)     #D&'#B$f--r{   c                "    t        dt              S )Ntype[Series[Any]])r
   r>   rv   s    ry   _serieszDataFrame._series   s    '00r{   c                "    t        dt              S )Ntype[LazyFrame[Any]])r
   r   r   s    ry   
_lazyframezDataFrame._lazyframe   s    *I66r{   c                     y N rv   items     ry   __getitem__zDataFrame.__getitem__   s    WZr{   c                     y r   r   r   s     ry   r   zDataFrame.__getitem__   s     r{   c                     y r   r   r   s     ry   r   zDataFrame.__getitem__   s     r{   c                "    t         |   |      S r   )rs   r   )rv   r   rx   s     ry   r   zDataFrame.__getitem__   s     w"4((r{   c                "    t         |   |      S r   )rs   
get_column)rv   namerx   s     ry   r   zDataFrame.get_column   s     w!$''r{   )sessionc               8    t        t        | 	  ||            S )N)r   r   )
_stableifyrs   lazy)rv   r   r   rx   s      ry   r   zDataFrame.lazy   s     %',w,HIIr{   .	as_seriesc                    y r   r   rv   r   s     ry   to_dictzDataFrame.to_dict   s    TWr{   c                    y r   r   r   s     ry   r   zDataFrame.to_dict   s    MPr{   Tc                    y r   r   r   s     ry   r   zDataFrame.to_dict   s     9<r{   c               $    t         |   |      S )Nr   )rs   r   )rv   r   rx   s     ry   r   zDataFrame.to_dict   s    
 w33r{   c                2    t        t        | 	               S r   )r   rs   is_duplicatedrv   rx   s    ry   r   zDataFrame.is_duplicated   s    %'/122r{   c                2    t        t        | 	               S r   )r   rs   	is_uniquer   s    ry   r   zDataFrame.is_unique   s    %'+-..r{   rw   r   ro   &Literal['full', 'lazy', 'interchange']returnNoner   rL   r   IntoBackend[EagerAllowed]r   ra   r   r   zMapping[str, Any]r   z#Mapping[str, DType] | Schema | Noner   z IntoBackend[EagerAllowed] | Noner   ra   r   r_   r   z3Mapping[str, DType] | Schema | Sequence[str] | Noner   r   r   ra   )r   r   )r   r   )r   z-tuple[SingleIndexSelector, SingleColSelector]r   r   )r   z2str | tuple[MultiIndexSelector, SingleColSelector]r   rf   )r   zSingleIndexSelector | MultiIndexSelector | MultiColSelector | tuple[SingleIndexSelector, MultiColSelector] | tuple[MultiIndexSelector, MultiColSelector]r   rK   )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   rd   )r   Literal[True]r   zdict[str, Series[Any]])r   Literal[False]r   zdict[str, list[Any]])r   boolr   z-dict[str, Series[Any]] | dict[str, list[Any]])r   rf   )__name__
__module____qualname__r   rr   rq   r   NwDataFramert   classmethodr   r   r   propertyr   r   r   r   r   r   r   r   r   __classcell__rx   s   @ry   r   r   d   s   zzH* * .).7P.	. .  7;.
 59.. 4.
 2. 
. .  GK.. D.
 +. 
. . 1 1 7 7 Z ZF	  	:	 
	 	):) 
")( 48J #	J0J 	J
 
J 47W WP P#'< <	6< < $(4 4	643/ /r{   r   c                  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 rn   rp   ru   s      ry   rt   zLazyFrame.__init__   rz   r{   c                    t         S r   r   r   s    ry   
_dataframezLazyFrame._dataframe       r{   c                8    t        t        |   dd|i|      S )Nr   r   )r   rs   collect)rv   r   kwargsrx   s      ry   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   ra   )
r   r   r   r   NwLazyFramert   r   r   r   r   r   s   @ry   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<    xZS )r>   r   c               d    |j                   t        j                  u sJ t        |   ||       y rn   rp   )rv   seriesro   rx   s      ry   rt   zSeries.__init__   s-     '**,,,u-r{   c                    t         S r   r   r   s    ry   r   zSeries._dataframe   r   r{   Nc               B    t         |   ||||      }t        d|      S Nr~   rf   r   r   r   valuesdtyper   r   rx   s         ry   r   zSeries.from_numpy   s*     #D&%#IM6**r{   c               B    t         |   ||||      }t        d|      S r   )rs   from_iterabler
   r   s         ry   r   zSeries.from_iterable  s*     &tVUG&LM6**r{   c                2    t        t        | 	               S r   )r   rs   to_framer   s    ry   r   zSeries.to_frame  s    %'*,--r{   Fsortparallelr   	normalizec               <    t        t        | 	  ||||            S )Nr   )r   rs   value_counts)rv   r   r   r   r   rx   s        ry   r   zSeries.value_counts  s-     G H49 ! 
 	
r{   hist)r   r   ro   r   r   r   r   r   )
r   r   r   r^   r   IntoDType | Noner   r   r   rf   )
r   r   r   zIterable[Any]r   r   r   r   r   rf   )r   ra   )
r   r   r   r   r   z
str | Noner   r   r   ra   )r   r   r   r   rr   rq   r   NwSeriesrt   r   r   r   r   r   r   r   r   r   __annotations__r   r   s   @ry   r>   r>      s:   zzH..%K.	. .   
 #'		+	+ 	+  		+ +	+ 
	+ 	+ 
 #'		+	+ 	+  		+ +	+ 
	+ 	+. 
 
 	

 
 
 

  !D#!r{   r>   c                      e Zd Zy)r9   N)r   r   r   r   r{   ry   r9   r9   '  s    r{   r9   c                  X     e Zd Zej                  Z ee      	 d	 	 	 d fd       Z xZ	S )r=   c                $    t         |   |       y r   )rs   rt   )rv   r   rx   s     ry   rt   zSchema.__init__-  s     	 r{   r   )r   z8Mapping[str, DType] | Iterable[tuple[str, DType]] | Noner   r   )
r   r   r   r   rr   rq   r   NwSchemart   r   r   s   @ry   r=   r=   *  s6    zzHQU!N!	! !r{   r=   c                     y r   r   objs    ry   r   r   4      ORr{   c                     y r   r   r   s    ry   r   r   6  r   r{   c                     y r   r   r   s    ry   r   r   8      CFr{   c                     y r   r   r   s    ry   r   r   :  s    %(r{   c                N   t        | t              r>t        | j                  j	                  t
        j                        | j                        S t        | t              r>t        | j                  j	                  t
        j                        | j                        S t        | t              r>t        | j                  j	                  t
        j                        | j                        S t        | t              r t        | j                  | j                         S t#        |        y rn   )
isinstancer   r   _compliant_frame_with_versionr   rr   _levelr   r   r   r>   _compliant_seriesNwExprr9   _to_compliant_expr	_metadatar   r   s    ry   r   r   >  s     #{#--;;GJJGszzZZ#{#--;;GJJGszzZZ#x c++99'**ESZZXX#vC**CMM::r{   c                     y r   r   native_objectkwdss     ry   from_nativer   O  s    ADr{   c                     y r   r   r   s     ry   r   r   S      GJr{   c                     y r   r   r   s     ry   r   r   W  r  r{   c                     y r   r   r   s     ry   r   r   [  s     "r{   .)
eager_onlyseries_onlyc                    y r   r   r   pass_throughr  r  allow_seriess        ry   r   r   a       !$r{   )r  c                    y r   r   r  s        ry   r   r   l  s     7:r{   )r  r  r	  c                    y r   r   r  s        ry   r   r   w  r
  r{   c                    y r   r   r  s        ry   r   r          	r{   )r  r	  c                    y r   r   r  s        ry   r   r     r
  r{   c                    y r   r   r  s        ry   r   r     r  r{   )r  r	  c                    y r   r   r  s        ry   r   r          r{   r  r  r  r	  c                    y r   r   r  s        ry   r   r     r
  r{   c                    y r   r   r  s        ry   r   r     r
  r{   )r  r  r	  c                    y r   r   r  s        ry   r   r     r
  r{   )r  r  r  c                    y r   r   r  s        ry   r   r     s     58r{   )r  r  r	  c                    y r   r   r  s        ry   r   r     r  r{   c                    y r   r   r  s        ry   r   r     s     r{   Fc                   t        | t        t        f      r|s| S t        | t              r|s|r| S |r"dt	        t        |            }t        |      t        | ||||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.
    z1from_native() got an unexpected keyword argument )r  r  r  r	  version)
r   r   r   r>   nextiter	TypeErrorrB   r   rr   )r   r  r  r  r	  r   msgs          ry   r   r     sv    Z -)Y!78-(k\A$tDzBRAUVn!!

 r{   r  c                    y r   r   narwhals_objectr  s     ry   	to_nativer$  1       r{   c                    y r   r   r"  s     ry   r$  r$  5  r%  r{   c                    y r   r   r"  s     ry   r$  r$  9  s     r{   c                    y r   r   r"  s     ry   r$  r$  =  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   )nwr$  r"  s     ry   r$  r$  A  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__
ValueErrorr$  )argsr   argr   valuevbbackendsr  r   r	  r  funcr  r  s             ry   wrapperz.narwhalify.<locals>.decorator.<locals>.wrapper  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)r4  r   r   r   r   r   r   )r:  r;  r	  r  r  r  s   ` ry   	decoratorznarwhalify.<locals>.decorator  s)    	t#	@ #	@ 
#	@J r{   )r:  Callable[..., Any]r   r=  r   )r:  r  r  r  r	  r<  s    ```` ry   
narwhalifyr>  W  s&    R' 'R |T?r{   c                 <    t        t        j                               S )z`Instantiate an expression representing all columns.

    Returns:
        A new expression.
    )r   r*  allr   r{   ry   r@  r@         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.

    Returns:
        A new expression.
    )r   r*  colnamess    ry   rC  rC    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.

    Returns:
        A new expression.
    )r   r*  excluderD  s    ry   rG  rG    s     bjj%())r{   c                 8    t        t        j                  |        S )aI  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.

    Returns:
        A new expression.
    )r   r*  nth)indicess    ry   rI  rI    s     bffg&''r{   c                 <    t        t        j                               S )zGReturn the number of rows.

    Returns:
        A new expression.
    )r   r*  lenr   r{   ry   rL  rL    rA  r{   c                @    t        t        j                  | |            S )a!  Return 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.

    Returns:
        A new expression.
    )r   r*  lit)r6  r   s     ry   rN  rN    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.

    Returns:
        A new expression.
    )r   r*  mincolumnss    ry   rP  rP         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.

    Returns:
        A new expression.
    )r   r*  maxrQ  s    ry   rU  rU    rS  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

    Returns:
        A new expression.
    )r   r*  meanrQ  s    ry   rW  rW    s     bggw'((r{   c                 8    t        t        j                  |        S )at  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

    Returns:
        A new expression.
    )r   r*  medianrQ  s    ry   rY  rY  $  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

    Returns:
        A new expression.
    )r   r*  sumrQ  s    ry   r[  r[  5  rS  r{   c                 8    t        t        j                  |        S )a2  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.

    Returns:
        A new expression.
    )r   r*  sum_horizontalexprss    ry   r]  r]  D       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.

    Returns:
        A new expression.
    ignore_nulls)r   r*  all_horizontalrb  r_  s     ry   rc  rc  T        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.

    Returns:
        A new expression.
    rb  )r   r*  any_horizontalrd  s     ry   rg  rg  g  re  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.

    Returns:
        A new expression.
    )r   r*  mean_horizontalr^  s    ry   ri  ri  z  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.

    Returns:
        A new expression.
    )r   r*  min_horizontalr^  s    ry   rk  rk    r`  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.

    Returns:
        A new expression.
    )r   r*  max_horizontalr^  s    ry   rm  rm    r`  r{    	separatorrb  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.

    Returns:
        A new expression.
    ro  )r   r*  
concat_str)r_  rp  rb  
more_exprss       ry   rr  rr    s)    , 
eYjYILY r{   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.

    Returns:
        A new expression.
    )r   r*  coalesce)r_  rs  s     ry   ru  ru    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     ry   	from_whenzWhen.from_when  s    4??##r{   c                H    t         j                  t        |   |            S r   )Then	from_thenrs   thenrv   r6  rx   s     ry   r  z	When.then  s    ~~egl5122r{   )rz  z	nw_f.Whenr   rw  )r6  &IntoExpr | NonNestedLiteral | _1DArrayr   r}  )r   r   r   r   r{  r  r   r   s   @ry   rw  rw    s    $ $3 3r{   rw  c                  2     e Zd Zedd       Zd fdZ xZS )r}  c                <     | |j                   |j                        S r   )r   r   )r   r  s     ry   r~  zThen.from_then  s    4**DNN;;r{   c                4    t        t        | 	  |            S r   )r   rs   	otherwiser  s     ry   r  zThen.otherwise  s    %'+E233r{   )r  z	nw_f.Thenr   r}  )r6  r  r   r9   )r   r   r   r   r~  r  r   r   s   @ry   r}  r}    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.
    )rw  r{  nw_frz  )
predicatess    ry   rz  rz    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`.

    Returns:
        A new Series
    r~   )r   r:   )r   r   r   r   s       ry   
new_seriesr    s    4 &tVUGLMMr{   c               B    t        t        j                  | |            S )as  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`.

    Returns:
        A new DataFrame.
    r~   )r   r  r   )r   r   s     ry   r   r     s    & doolGDEEr{   r~   c               D    t        t        j                  | ||            S )a  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.
        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`.

    Returns:
        A new DataFrame.
    r~   )r   r  r   r   r   r   s      ry   r   r   2  s    @ dnnT67CDDr{   c               D    t        t        j                  | ||            S )aU  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`.

    Returns:
        A new DataFrame.
    r~   )r   r  r   r  s      ry   r   r   U  s    : 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')`.

    Returns:
        DataFrame.
    r   )r   r  read_csvsourcer   r   s      ry   r  r  u  s"    * dmmFFGFvFGGr{   c               D    t        t        j                  | fd|i|      S )as  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')`.

    Returns:
        LazyFrame.
    r   )r   r  scan_csvr  s      ry   r  r    s"    0 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')`.

    Returns:
        DataFrame.
    r   )r   r  read_parquetr  s      ry   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')`.

    Returns:
        LazyFrame.
    r   )r   r  scan_parquetr  s      ry   r  r    s%    L d''JJ6JKKr{   )Rr   r   r   r    r   r!   r"   r#   r$   r%   r9   r&   r'   r(   r   r)   r*   r+   r,   r-   r   r.   r/   r=   r>   r0   r1   r2   r3   r4   r5   r6   r7   r8   r@  rc  rg  ru  rC  r;   rr  r?   r@   r@   r   rG  r   r   r   r   r   rC   r   rL  rN  rU  rm  r   r   r   r   r   rW  ri  rY  rP  rk  r>  r  rI  r  r  r  r  rA   rA   r<   r[  r]  r$  rD   rz  )r   zNwDataFrame[IntoDataFrameT]r   DataFrame[IntoDataFrameT])r   zNwLazyFrame[IntoLazyFrameT]r   LazyFrame[IntoLazyFrameT])r   zNwSeries[IntoSeriesT]r   Series[IntoSeriesT])r   r   r   r9   )r   zZNwDataFrame[IntoDataFrameT] | NwLazyFrame[IntoLazyFrameT] | NwSeries[IntoSeriesT] | NwExprr   zRDataFrame[IntoDataFrameT] | LazyFrame[IntoLazyFrameT] | Series[IntoSeriesT] | Expr)r   re   r   r   r   re   )r   r`   r   r   r   r`   )r   rc   r   r   r   rc   )r   DataFrameT | LazyFrameTr   r   r   r  )r   zIntoDataFrameT | IntoSeriesr  r   r  r   r  r   r	  r   r   r  )r   zIntoDataFrameT | IntoSeriesTr  r   r  r   r  r   r	  r   r   z/DataFrame[IntoDataFrameT] | Series[IntoSeriesT])r   rE   r  r   r  r   r  r   r	  r   r   r  )r   rg   r  r   r  r   r  r   r	  r   r   rg   )r   rE   r  r   r  r   r  r   r	  r   r   r  )r   rg   r  r   r  r   r  r   r	  r   r   rg   )r   rk   r  r   r  r   r  r   r	  r   r   r  )r   rE   r  r   r  r   r  r   r	  r   r   r  )r   rF   r  r   r  r   r  r   r	  r   r   r  )r   rE   r  r   r  r   r  r   r	  r   r   r  )r   zIntoFrame | IntoSeriesr  r   r  r   r  r   r	  r   r   z-DataFrame[Any] | LazyFrame[Any] | Series[Any])r   rk   r  r   r  r   r  r   r	  r   r   r  )r   r   r  r   r  r   r  r   r	  bool | Noner   r   )r   zJIntoDataFrameT | IntoLazyFrameT | IntoFrame | IntoSeriesT | IntoSeries | Tr  r   r  r   r  r   r	  r  r   r   r   zOLazyFrame[IntoLazyFrameT] | DataFrame[IntoDataFrameT] | Series[IntoSeriesT] | T)r#  r  r  r   r   rE   )r#  r  r  r   r   rF   )r#  r  r  r   r   rk   )r#  r   r  r   r   r   )r#  zKDataFrame[IntoDataFrameT] | LazyFrame[IntoLazyFrameT] | Series[IntoSeriesT]r  r   r   z3IntoDataFrameT | IntoLazyFrameT | IntoSeriesT | Anyr   )r:  zCallable[..., Any] | Noner  r   r  r   r  r   r	  r  r   r=  )r   r9   )rE  zstr | Iterable[str]r   r9   )rJ  zint | Sequence[int]r   r9   )r6  r[   r   r   r   r9   )rR  r   r   r9   )r_  IntoExpr | Iterable[IntoExpr]r   r9   )r_  r  rb  r   r   r9   )
r_  r  rs  rX   rp  r   rb  r   r   r9   )r_  r  rs  rX   r   r9   )r  r  r   rw  )
r   r   r   r   r   r   r   r   r   rf   r   r   r   )r  r   r   r   r   r   r   ra   )r  r   r   zIntoBackend[Backend]r   r   r   rd   )
__future__r   	functoolsr   typingr   r   r   r	   r
   r   narwhalsr*  r   r   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+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   narwhals.exprr9   r   narwhals.functionsr:   r;   r<   narwhals.schemar=   r   narwhals.seriesr>   r   narwhals.stable.v2r?   r@   rA   narwhals.translaterB   rC   rD   narwhals.typingrE   rF   collections.abcrG   rH   rI   typing_extensionsrJ   rK   narwhals._translaterL   narwhals._typingrM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   rc   re   rg   ri   rj   rk   r   r   r$  r>  r@  rC  rG  rI  rL  rN  rP  rU  rW  rY  r[  r]  rc  rg  ri  rk  rm  rr  ru  rw  r}  rz  r  r   r   r   r  r  r  r  __all__r   r{   ry   <module>r     s:
   "  H H  2 9    R       < ) F F . . > > T T :;;12   H%
 
 
 -=>J-=>Ji}5GS!A#AAm<Er/N+ r/jFN+ F ;"Xk" ;"| 6 !X ! 
 R 
 R	 R 
 R	 F 
 F	 ( 
 (

 X" 
 D 
 D 
 J 
 J 
 J 
 J 
"*"47"" 
"
 

 "%"%$.$  $ 	$
  $  $ $ 
$ 
 #&:/:  : 	:
  :  : 5: 
: 

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

 "%"%   	
     
 
 #&$!$  $ 	$
  $ $ $ 
$ 
 #&   	
     
 

 "%   	
    
 
 $'!$"%$!$ !$ 	$
  $ $ $ 
$ 
 $'!$"%$!$ !$ 	$
  $ $ $ 
$ 
 $'"%$!$ !$ 	$
  $ $ $ 
$ 
 $'!$"%8)8 !8 	8
  8  8 38 
8 
 $'!$ ! 	
    
 
  	
   	 
$  $== = = = = = U=@ 
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& 	(  	
 
67&3499 34499d 426 #N
NN N
 'N N:F F.GFF0 37 E 15	 E
 E/ E .	 E
  EJ CGF
F?F '	F
 F@HH6HBEHH0HH1H=@HH6LL6LBELL0&L&L1&L=@&L&LRSr{   