
    hh                    *   U d dl mZ d dlmZ d dlmZmZmZmZm	Z	m
Z
mZ d dlZd dlmZmZ d dlmZ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/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZA d d
lBmCZD d dlEmFZFmGZGmHZH d dlImJZK d dlLmMZN d dlOmPZPmQZQmRZR d dlSmTZTmUZUmVZV d dlWmXZXmYZY erd dlZm[Z[m\Z\m]Z] d dl^m_Z_m`Z` d dlambZb d dlcmdZdmeZemfZfmgZgmhZhmiZimjZj d dl mkZkmlZl d dl%mmZm d dlWmnZnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZw  edd          Zx edd          Zy edd          Zz ede           Z{ e_d!          Z| ed"          Z} ed#d$e%          Z~ G d& d'e"eX                   Z! G d( d)e$eY                   Z# G d* d+eNe~                   ZM G d, d-eD          ZC G d. d/eK          ZJedd4            Zedd7            Zedd:            Zedd<            Zdd?ZeddC            ZeddD            ZeddE            ZeddG            ZedHdHdIddQ            ZedHdRddU            ZedHdHdHdVddY            ZedHdHdHdVddZ            ZedHdHd[dd\            ZedHdHd[dd]            ZedHdHd^dd_            ZedHdHdHdHd`dda            ZedHdHdHdHd`ddc            ZedHdHdHdddde            ZedHdHdHdfddi            ZedHdHdHdjddk            Zeddn            Zdodododd`ddrZedHdsddu            ZedHdsddv            ZedHdsddw            Zeddx            Zdodsdd{Z	 dd|dodod|d`ddZddZddZddZddZddZdddZddZddZddZddZddZddZddZddZddZddZddZddodddZddZddZ G d dej                  Z G d dej        eC          ZddZ	 dddZddZ	 dddddZe!j        Zded<   	 dddZddńZddǄZddȄZddɄZg dʢZdS )    )annotationswraps)TYPE_CHECKINGAnyCallableFinal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
IntoSchema
IntoSeriesNonNestedLiteralSingleColSelectorSingleIndexSelector_1DArray_2DArray
DataFrameTDataFrame[Any])bound
LazyFrameTLazyFrame[Any]SeriesTSeries[Any]T)defaultPRIntoSeriesTr\   )rd   rj   c                      e Zd Zej        Z ee          dF fd            Ze	dG fd            Z
e		 dHdddI fd            Ze		 dHdJ fd            Ze		 dHdK fd            ZedLd            ZedMd            ZedNd"            ZedOd%            ZedPd(            ZdQ fd+ZdR fd/Z	 dHdd0dS fd5Zed6d7dTd;            ZedUd>            Zed?d7dVdB            Zd?d7dV fdCZdW fdDZdW fdEZ xZS )Xr   dfr   level&Literal['full', 'lazy', 'interchange']returnNonec               x    |j         t          j        u sJ t                                          ||           d S N)rp   _versionr   V2super__init__selfro   rp   	__class__s      R/var/www/histauto/venv/lib/python3.11/site-packages/narwhals/stable/v2/__init__.pyrz   zDataFrame.__init__h   ;    {gj((((5)))))    native_framerM   backendIntoBackend[EagerAllowed]rc   c               j    t                                          ||          }t          d|          S Nr   rc   )ry   
from_arrowr   )clsr   r   resultr}   s       r~   r   zDataFrame.from_arrowp   s2     ##L'#BB$f---r   Nr   dataMapping[str, Any]schema#Mapping[str, DType] | Schema | None IntoBackend[EagerAllowed] | Nonec               l    t                                          |||          }t          d|          S r   )ry   	from_dictr   r   r   r   r   r   r}   s        r~   r   zDataFrame.from_dictw   s4     ""4"AA$f---r   Sequence[Mapping[str, Any]]IntoSchema | Nonec               l    t                                          |||          }t          d|          S r   )ry   
from_dictsr   r   s        r~   r   zDataFrame.from_dicts   4     ##D&'#BB$f---r   ra   3Mapping[str, DType] | Schema | Sequence[str] | Nonec               l    t                                          |||          }t          d|          S r   ry   
from_numpyr   r   s        r~   r   zDataFrame.from_numpy   r   r   type[Series[Any]]c                ,    t          dt                    S )Nr   )r   r?   r|   s    r~   _serieszDataFrame._series   s    '000r   type[LazyFrame[Any]]c                ,    t          dt                    S )Nr   )r   r   r   s    r~   
_lazyframezDataFrame._lazyframe   s    *I666r   item-tuple[SingleIndexSelector, SingleColSelector]c                    d S N r|   r   s     r~   __getitem__zDataFrame.__getitem__   s    WZWZr   2str | tuple[MultiIndexSelector, SingleColSelector]rh   c                    d S r   r   r   s     r~   r   zDataFrame.__getitem__   s	     cr   SingleIndexSelector | MultiIndexSelector | MultiColSelector | tuple[SingleIndexSelector, MultiColSelector] | tuple[MultiIndexSelector, MultiColSelector]rL   c                    d S r   r   r   s     r~   r   zDataFrame.__getitem__   s	     sr     SingleIndexSelector | SingleColSelector | MultiColSelector | MultiIndexSelector | tuple[SingleIndexSelector, SingleColSelector] | tuple[SingleIndexSelector, MultiColSelector] | tuple[MultiIndexSelector, SingleColSelector] | tuple[MultiIndexSelector, MultiColSelector]Series[Any] | Self | Anyc                F    t                                          |          S r   )ry   r   )r|   r   r}   s     r~   r   zDataFrame.__getitem__   s     ww""4(((r   namestrr?   c                F    t                                          |          S r   )ry   
get_column)r|   r   r}   s     r~   r   zDataFrame.get_column   s     ww!!$'''r   )sessionIntoBackend[LazyAllowed] | Noner   
Any | Nonerf   c               d    t          t                                          ||                    S )N)r   r   )
_stableifyry   lazy)r|   r   r   r}   s      r~   r   zDataFrame.lazy   s'     %'',,w,HHIIIr   .	as_seriesr   Literal[True]dict[str, Series[Any]]c                   d S r   r   r|   r   s     r~   to_dictzDataFrame.to_dict   s    TWTWr   Literal[False]dict[str, list[Any]]c                   d S r   r   r   s     r~   r   zDataFrame.to_dict   s    MPSr   Tbool-dict[str, Series[Any]] | dict[str, list[Any]]c                   d S r   r   r   s     r~   r   zDataFrame.to_dict   s	     9<r   c               H    t                                          |          S )Nr   )ry   r   )r|   r   r}   s     r~   r   zDataFrame.to_dict   s    
 ww333r   c                ^    t          t                                                                S r   )r   ry   is_duplicatedr|   r}   s    r~   r   zDataFrame.is_duplicated   s!    %''//11222r   c                ^    t          t                                                                S r   )r   ry   	is_uniquer   s    r~   r   zDataFrame.is_unique   s!    %''++--...r   ro   r   rp   rq   rr   rs   r   rM   r   r   rr   rc   r   r   r   r   r   r   r   rr   rc   )r   r   r   r   r   r   rr   rc   r   ra   r   r   r   r   rr   rc   )rr   r   )rr   r   )r   r   rr   r   )r   r   rr   rh   )r   r   rr   rL   )r   r   rr   r   )r   r   rr   r?   )r   r   r   r   rr   rf   )r   r   rr   r   )r   r   rr   r   )r   r   rr   r   )rr   rh   )__name__
__module____qualname__r   rx   rw   r   NwDataFramerz   classmethodr   r   r   r   propertyr   r   r   r   r   r   r   r   r   __classcell__r}   s   @r~   r   r   e   s       zH[* * * * * * . . . . . [.  7;.
 59. . . . . . . [.  %). . . . . . [.  GK. . . . . . [. 1 1 1 X1 7 7 7 X7 ZZZ XZ   X 	 	 	 X	) ) ) ) ) )( ( ( ( ( ( 48J #	J J J J J J J J 47WWWWW XWPPP XP#'< < < < < X< $(4 4 4 4 4 4 4 43 3 3 3 3 3/ / / / / / / / / /r   r   c                  j     e Zd Z ee          d fd            Zedd	            Z	 dd fdZ xZ	S )r   ro   r   rp   rq   rr   rs   c               x    |j         t          j        u sJ t                                          ||           d S ru   rv   r{   s      r~   rz   zLazyFrame.__init__   r   r   type[DataFrame[Any]]c                    t           S r   r   r   s    r~   
_dataframezLazyFrame._dataframe       r   Nr   +IntoBackend[Polars | Pandas | Arrow] | Nonekwargsrc   c                T    t           t                      j        dd|i|          S )Nr   r   )r   ry   collect)r|   r   r   r}   s      r~   r   zLazyFrame.collect   s.     /%''/DD'DVDDEEEr   r   rr   r   r   )r   r   r   r   rr   rc   )
r   r   r   r   NwLazyFramerz   r   r   r   r   r   s   @r~   r   r      s        [* * * * * *    X FJF F F F F F F F 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?   seriesr   rp   rq   rr   rs   c               x    |j         t          j        u sJ t                                          ||           d S ru   rv   )r|   r   rp   r}   s      r~   rz   zSeries.__init__   s=     '*,,,,u-----r   r   c                    t           S r   r   r   s    r~   r   zSeries._dataframe  r   r   Nr   r   valuesr`   dtypeIntoDType | Noner   r   rh   c               n    t                                          ||||          }t          d|          S Nr   rh   r   r   r   r   r   r   r   r}   s         r~   r   zSeries.from_numpy  s5     ##D&%#IIM6***r   Iterable[Any]c               n    t                                          ||||          }t          d|          S r   )ry   from_iterabler   r   s         r~   r   zSeries.from_iterable  s5     &&tVUG&LLM6***r   rc   c                ^    t          t                                                                S r   )r   ry   to_framer   s    r~   r   zSeries.to_frame  s!    %''**,,---r   Fsortparallelr   	normalizer   r   r   
str | Noner   c               h    t          t                                          ||||                    S )Nr   )r   ry   value_counts)r|   r   r   r   r   r}   s        r~   r   zSeries.value_counts!  s<     GG  H49 !  
 
 	
r   hist)r   r   rp   rq   rr   rs   r   r   )
r   r   r   r`   r   r   r   r   rr   rh   )
r   r   r   r   r   r   r   r   rr   rh   )rr   rc   )
r   r   r   r   r   r   r   r   rr   rc   )r   r   r   r   rx   rw   r   NwSeriesrz   r   r   r   r   r   r   r   r   r   __annotations__r   r   s   @r~   r?   r?      sJ        zH[. . . . . .    X 
 #'		+ 	+ 	+ 	+ 	+ 	+ [	+ 
 #'		+ 	+ 	+ 	+ 	+ 	+ [	+. . . . . . 
 
 
 
 
 
 
 
  !!D!!!!!!!!r   r?   c                      e Zd ZdS )r:   N)r   r   r   r   r   r~   r:   r:   3  s          r   r:   c                  T     e Zd Zej        Z ee          	 dd fd            Z xZ	S )	r>   Nr   8Mapping[str, DType] | Iterable[tuple[str, DType]] | Nonerr   rs   c                J    t                                          |           d S r   )ry   rz   )r|   r   r}   s     r~   rz   zSchema.__init__9  s#     	     r   r   )r   r  rr   rs   )
r   r   r   r   rx   rw   r   NwSchemarz   r   r   s   @r~   r>   r>   6  sa        zH[QU! ! ! ! ! ! ! ! ! ! !r   r>   objNwDataFrame[IntoDataFrameT]rr   DataFrame[IntoDataFrameT]c                    d S r   r   r  s    r~   r   r   @      ORsr   NwLazyFrame[IntoLazyFrameT]LazyFrame[IntoLazyFrameT]c                    d S r   r   r  s    r~   r   r   B  r	  r   NwSeries[IntoSeriesT]Series[IntoSeriesT]c                    d S r   r   r  s    r~   r   r   D      CF3r   NwExprc                    d S r   r   r  s    r~   r   r   F  s    %(Sr   ZNwDataFrame[IntoDataFrameT] | NwLazyFrame[IntoLazyFrameT] | NwSeries[IntoSeriesT] | NwExprRDataFrame[IntoDataFrameT] | LazyFrame[IntoLazyFrameT] | Series[IntoSeriesT] | Exprc                P   t          | t                    r8t          | j                            t
          j                  | j                  S t          | t                    r8t          | j                            t
          j                  | j                  S t          | t                    r8t          | j                            t
          j                  | j                  S t          | t                    rt          | j        | j                  S t#          |            d S ru   )
isinstancer   r   _compliant_frame_with_versionr   rx   _levelr   r   r   r?   _compliant_seriesr  r:   _to_compliant_expr	_metadatar   r  s    r~   r   r   J  s     #{## [-;;GJGGszZZZZ#{## [-;;GJGGszZZZZ#x   Yc+99'*EESZXXXX#v ;C*CM:::r   native_objectkwdsr   c                    d S r   r   r  r  s     r~   from_nativer!  [  s    ADr   c                    d S r   r   r   s     r~   r!  r!  _      GJsr   c                    d S r   r   r   s     r~   r!  r!  c  r#  r   DataFrameT | LazyFrameTc                    d S r   r   r   s     r~   r!  r!  g  s	     "cr   .)
eager_onlyseries_onlyIntoDataFrameT | IntoSeriespass_throughr   r'  r   r(  allow_seriesc                   d S r   r   r  r*  r'  r(  r+  s        r~   r!  r!  m  	     !$r   )r(  IntoDataFrameT | IntoSeriesT/DataFrame[IntoDataFrameT] | Series[IntoSeriesT]c                   d S r   r   r-  s        r~   r!  r!  x  s	     7:cr   )r'  r(  r+  rF   rs   c                   d S r   r   r-  s        r~   r!  r!    r.  r   c                   d S r   r   r-  s        r~   r!  r!    	     	r   )r(  r+  c                   d S r   r   r-  s        r~   r!  r!    r.  r   c                   d S r   r   r-  s        r~   r!  r!    r4  r   )r'  r+  c                   d S r   r   r-  s        r~   r!  r!    	     #r   r*  r'  r(  r+  c                   d S r   r   r-  s        r~   r!  r!    r.  r   rG   c                   d S r   r   r-  s        r~   r!  r!    r.  r   )r*  r(  r+  c                   d S r   r   r-  s        r~   r!  r!    r.  r   )r*  r'  r(  IntoFrame | IntoSeries-DataFrame[Any] | LazyFrame[Any] | Series[Any]c                   d S r   r   r-  s        r~   r!  r!    s	     58Cr   )r*  r'  r+  c                   d S r   r   r-  s        r~   r!  r!    r8  r   r   bool | Nonec                   d S r   r   r-  s        r~   r!  r!    s	     #r   FJIntoDataFrameT | IntoLazyFrameT | IntoFrame | IntoSeriesT | IntoSeries | TOLazyFrame[IntoLazyFrameT] | DataFrame[IntoDataFrameT] | Series[IntoSeriesT] | Tc                  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	TypeErrorrC   r   rx   )r  r*  r'  r(  r+  r  msgs          r~   r!  r!    s    Z -)Y!788  -(( k \  V$tDzzBRBRVVnn!!
   r   r*  narwhals_objectc                   d S r   r   rL  r*  s     r~   	to_nativerO  =  	     Sr   c                   d S r   r   rN  s     r~   rO  rO  A  rP  r   c                   d S r   r   rN  s     r~   rO  rO  E  s	     #r   c                   d S r   r   rN  s     r~   rO  rO  I  r  r   KDataFrame[IntoDataFrameT] | LazyFrame[IntoLazyFrameT] | Series[IntoSeriesT]3IntoDataFrameT | IntoLazyFrameT | IntoSeriesT | Anyc               .    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.
    rK  )nwrO  rN  s     r~   rO  rO  M  s    & <lCCCCr   TfuncCallable[..., Any] | NoneCallable[..., Any]c               :    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.
    rX  rZ  rr   c                H     t                     d fd            }|S )Nargsr   r   rr   c                 <   	
fd| D             } 	
fd|                                 D             }fdg | |                                R D             }|                                dk    rd}t          |           | i |}t	          |	          S )Nc           	     8    g | ]}t          |           S r9  r!  ).0argr+  r'  r*  r(  s     r~   
<listcomp>zBnarwhalify.<locals>.decorator.<locals>.wrapper.<locals>.<listcomp>  sI     	 	 	  !-) +!-  	 	 	r   c           
     @    i | ]\  }}|t          |           S r`  ra  )rb  r   valuer+  r'  r*  r(  s      r~   
<dictcomp>zBnarwhalify.<locals>.decorator.<locals>.wrapper.<locals>.<dictcomp>  sO     	 	 	  D% k!-) +!-  	 	 	r   c                J    h | ]}t          |d d          x              S )__native_namespace__N)getattr)rb  vbs     r~   	<setcomp>zAnarwhalify.<locals>.decorator.<locals>.wrapper.<locals>.<setcomp>  sG        $:DAAAA  r      z_Found multiple backends. Make sure that all dataframe/series inputs come from the same backend.rK  )itemsr   __len__
ValueErrorrO  )r]  r   backendsrJ  r   rl  r+  r'  rX  r*  r(  s        @r~   wrapperz.narwhalify.<locals>.decorator.<locals>.wrapper  s   	 	 	 	 	 	 	  	 	 	D	 	 	 	 	 	 	 $*<<>>	 	 	F   242&--//22  H !!A%%w oo%T4*6**FV,????r   )r]  r   r   r   rr   r   r   )rX  rs  r+  r'  r*  r(  s   ` r~   	decoratorznarwhalify.<locals>.decorator  sX    	t#	@ #	@ #	@ #	@ #	@ #	@ #	@ #	@ #	@ 
#	@J r   N)rX  rZ  rr   rZ  r   )rX  r*  r'  r(  r+  rt  s    ```` r~   
narwhalifyru  c  sP    R' ' ' ' ' ' ' ' 'R |9T??r   c                 B    t          t          j                              S )z3Instantiate an expression representing all columns.)r   rW  allr   r   r~   rw  rw        bfhhr   namesstr | Iterable[str]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   rW  colry  s    r~   r|  r|    s     bfen%%%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   rW  excluder}  s    r~   r  r    s     bj%()))r   indicesint | Sequence[int]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   rW  nth)r  s    r~   r  r    s     bfg&'''r   c                 B    t          t          j                              S )zReturn the number of rows.)r   rW  lenr   r   r~   r  r    rx  r   rf  r]   r   r   c                F    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   rW  lit)rf  r   s     r~   r  r    s     bfUE**+++r   columnsr   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   rW  minr  s    r~   r  r         bfg&'''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   rW  maxr  s    r~   r  r    r  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   rW  meanr  s    r~   r  r    s     bgw'(((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   rW  medianr  s    r~   r  r    s     bi)***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   rW  sumr  s    r~   r  r  !  r  r   exprsIntoExpr | Iterable[IntoExpr]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   rW  sum_horizontalr  s    r~   r  r  -       b'/000r   ignore_nullsc                >    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   rW  all_horizontalr  r  s     r~   r  r  :  "     b'J\JJK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   rW  any_horizontalr  s     r~   r  r  J  r  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   rW  mean_horizontalr  s    r~   r  r  Z  s     b(%01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   rW  min_horizontalr  s    r~   r  r  d  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.
    )r   rW  max_horizontalr  s    r~   r  r  q  r  r    	separatorr  
more_exprsrY   r  c               H    t          t          j        | g|R ||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   rW  
concat_str)r  r  r  r  s       r~   r  r  ~  s5    & 
eYjYYILYYY  r   f_stringr]  c                @    t          t          j        | g|R            S )zFormat expressions as a string.

    Arguments:
        f_string: A string that with placeholders.
        args: Expression(s) that fill the placeholders.
    )r   rW  format)r  r]  s     r~   r  r    s$     bi04000111r   c                @    t          t          j        | g|R            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   rW  coalesce)r  r  s     r~   r  r    s$     bk%5*555666r   c                  8     e Zd Zed	d            Zd
 fdZ xZS )Whenwhen	nw_f.Whenrr   c                "     | |j                   S r   )
_predicate)r   r  s     r~   	from_whenzWhen.from_when  s    s4?###r   rf  &IntoExpr | NonNestedLiteral | _1DArrayThenc                v    t                               t                                          |                    S r   )r  	from_thenry   thenr|   rf  r}   s     r~   r  z	When.then  s%    ~~eggll511222r   )r  r  rr   r  )rf  r  rr   r  )r   r   r   r   r  r  r   r   s   @r~   r  r    s[        $ $ $ [$3 3 3 3 3 3 3 3 3 3r   r  c                  8     e Zd Zed	d            Zd
 fdZ xZS )r  r  	nw_f.Thenrr   c                .     | |j         |j                  S r   )r  r  )r   r  s     r~   r  zThen.from_then  s    s4*DN;;;r   rf  r  r:   c                `    t          t                                          |                    S r   )r   ry   	otherwiser  s     r~   r  zThen.otherwise  s#    %''++E22333r   )r  r  rr   r  )rf  r  rr   r:   )r   r   r   r   r  r  r   r   s   @r~   r  r    s[        < < < [<4 4 4 4 4 4 4 4 4 4r   r  
predicatesc                 N    t                               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  )r  s    r~   r  r    s    * >>$)Z0111r   r   r   r   r   c               B    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LLMMMr   r   rM   c               H    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!      dolGDDDEEEr   r   r   r   r   r   r   c               J    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`.
    r   )r   r  r   r   r   r   s      r~   r   r     s#    : dnT67CCCDDDr   r	   r   ra   r   c               J    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 dodFGDDDEEEr   sourcer   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r  r   r   s      r~   r  r  G  s)    $ dmFFFGFvFFGGGr   IntoBackend[Backend]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)    * dmFFFGFvFFG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  t  s*    $ d'JJJ6JJK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    s+    F d'JJJ6JJKKKr   )Tr   r   r    r!   r   r"   r#   r$   r%   r&   r:   r'   r(   r)   r   r*   r+   r,   r-   r.   r   r/   r0   r>   r?   r1   r2   r3   r4   r5   r6   r7   r8   r9   rw  r  r  r  r|  r<   r  r@   rA   rA   r   r  r  r   r   r   r!  r   r   rD   r   r  r  r  r  r   r   r   r   r   r  r  r  r  r  ru  r  r  r  r  r  r  rB   rB   r=   r  r  rO  rE   r  )r  r  rr   r  )r  r
  rr   r  )r  r  rr   r  )r  r  rr   r:   )r  r  rr   r  )r  rg   r  r   rr   rg   )r  rb   r  r   rr   rb   )r  re   r  r   rr   re   )r  r%  r  r   rr   r%  )r  r)  r*  r   r'  r   r(  r   r+  r   rr   r  )r  r/  r*  r   r'  r   r(  r   r+  r   rr   r0  )r  rF   r*  r   r'  r   r(  r   r+  rs   rr   r  )r  ri   r*  r   r'  r   r(  r   r+  rs   rr   ri   )r  rF   r*  r   r'  r   r(  r   r+  rs   rr   r  )r  ri   r*  r   r'  r   r(  r   r+  rs   rr   ri   )r  rm   r*  r   r'  r   r(  r   r+  rs   rr   r  )r  rF   r*  r   r'  r   r(  r   r+  rs   rr   r  )r  rG   r*  r   r'  r   r(  r   r+  rs   rr   r  )r  rF   r*  r   r'  r   r(  r   r+  rs   rr   r  )r  r=  r*  r   r'  r   r(  r   r+  r   rr   r>  )r  rm   r*  r   r'  r   r(  r   r+  rs   rr   r  )r  r   r*  r   r'  r   r(  r   r+  rA  rr   r   )r  rC  r*  r   r'  r   r(  r   r+  rA  r  r   rr   rD  )rL  r  r*  r   rr   rF   )rL  r  r*  r   rr   rG   )rL  r  r*  r   rr   rm   )rL  r   r*  r   rr   r   )rL  rT  r*  r   rr   rU  r   )rX  rY  r*  r   r'  r   r(  r   r+  rA  rr   rZ  )rr   r:   )ry  rz  rr   r:   )r  r  rr   r:   )rf  r]   r   r   rr   r:   )r  r   rr   r:   )r  r  rr   r:   )r  r  r  r   rr   r:   )
r  r  r  rY   r  r   r  r   rr   r:   )r  r   r]  rY   rr   r:   )r  r  r  rY   rr   r:   )r  r  rr   r  )
r   r   r   r   r   r   r   r   rr   rh   r   r   r   )r  r   r   r   r   r   rr   rc   )r  r   r   r  r   r   rr   rf   )
__future__r   	functoolsr   typingr   r   r   r	   r
   r   r   narwhalsrW  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/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   narwhals.exprr:   r  narwhals.functionsr;   r<   r=   narwhals.schemar>   r  narwhals.seriesr?   r   narwhals.stable.v2r@   rA   rB   narwhals.translaterC   rD   rE   narwhals.typingrF   rG   collections.abcrH   rI   rJ   typing_extensionsrK   rL   narwhals._translaterM   narwhals._typingrN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   re   rg   ri   rk   rl   rm   r   r!  rO  ru  rw  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r   r  r  r  r  __all__r   r   r~   <module>r     s   " " " " " " "       O O O O O O O O O O O O O O O O O O     2 2 2 2 2 2 2 2 9 9 9 9 9 9 9 9                          R Q Q Q Q Q Q Q                                                           < ) ( ( ( ( ( F F F F F F F F F F . . . . . . . . . . . . > > > > > > > > > > T T T T T T T T T T : : : : : : : : #;;;;;;;;;;11111111222222                  HGGGGGGG%%%%%%                        -=>>>J-=>>>Jgi}555GS!!!A	#AAgm<EEE}/ }/ }/ }/ }/N+ }/ }/ }/@F F F F FN+ F F F ;" ;" ;" ;" ;"Xk" ;" ;" ;"|     6   ! ! ! ! !X ! ! ! 
 R R R 
 R	 R R R 
 R	 F F F 
 F	 ( ( ( 
 (   " 
 D D D 
 D 
 J J J 
 J 
 J J J 
 J 
" " " 
"
 

 "%"%$ $ $ $ $ 
$ 
 #&: : : : : 
: 

 "%"%$ $ $ $ $ 
$ 

 "%"%     
 
 #&$ $ $ $ $ 
$ 
 #&     
 

 "%     
 
 $'!$"%$ $ $ $ $ 
$ 
 $'!$"%$ $ $ $ $ 
$ 
 $'"%$ $ $ $ $ 
$ 
 $'!$"%8 8 8 8 8 
8 
 $'!$     
 
   
$  $= = = = = =@ 
RU     
 
RU     
 
LO     
 
 F F F 
 F D D D D D D. '+U  $U U U U U Up       
& & & &* * * *
( 
( 
( 
(       
, , , , ,	( 	( 	( 	(	( 	( 	( 	(	) 	) 	) 	)+ + + +	( 	( 	( 	(
1 
1 
1 
1L L L L L L L L 2 2 2 2
1 
1 
1 
1
1 
1 
1 
1  	     02 2 2 27 7 7 7 3 3 3 3 349 3 3 34 4 4 4 449d 4 4 42 2 2 26 #N N N N N4F F F F* 37E 15	E E E E E E@ (
 ( ( ( (
 CGF F F F F:H H H H*H H H H0L L L L*#L #L #L #LLU U Ur   