
    Lpjy                   D   % S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	J
r
JrJrJrJrJrJrJr  S SKJr  S SKJrJrJr  S SKJrJrJrJr  S S	KJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2  S S
K3J4r4J5r5  S SK6J7r7J8r8J9r9  S SK:J;r;J<r<  S SK=J>r>  S SK?J@r@  S SKAJBrB  \	(       a  S SKCJDrDJErEJFrFJGrGJHrH  S SKIJJrJ  S SKKJLrL  S SKMJNrN  S SKJOrOJPrP  S SKQrRS SKSrTS SKUrVS SKWJXrXJYrY  S SKZJ[r[J\r\  S SK]J^r^  S SKJ_r_  S SK`Jara  S SKJbrbJcrcJdrdJereJfrf  S SKgJhrhJiri  S SKjJkrkJlrlJmrmJnrnJoroJprpJqrqJrrrJsrtJurvJwrwJxrxJyryJzrzJ{r{J|r|  \X" S5      r}\
r~S\S '   \" S!S"S#9r\" S$S%S#9r\" S&S'S#9r\" S(5      rS)rsS\S*'   S+ruS\S,'    " S- S.\\   5      r " S/ S0\\   5      r " S1 S2\\   5      rg)3    )annotations)abstractmethod)partial)chain)	TYPE_CHECKINGAnyClassVarGenericLiteralNoReturnTypeVarget_argsoverload)issue_warning)_parse_into_expr!check_expressions_preserve_lengthis_scalar_like)ArrowPandas_LazyAllowedImpl_LazyFrameCollectImpl)ImplementationVersion_Implementation_resolve_sample_sizecan_lazyframe_collectcheck_columns_existflattengenerate_repris_compliant_dataframeis_compliant_lazyframeis_eager_allowedis_index_selectoris_iteratoris_lazy_allowed
is_list_ofis_sequence_likeis_sequence_ofis_slice_none predicates_contains_list_of_boolqualified_type_namesupports_arrow_c_stream)is_numpy_array_2dis_pyarrow_table)ColumnNotFoundErrorInvalidOperationErrorPerformanceWarning)_from_dict_no_backend_is_into_schema)SchemaSeries	to_native)CallableIterableIteratorMappingSequence)BytesIO)Path)
ModuleType)Concatenate	TypeAliasN)	ParamSpecSelf)CompliantDataFrameCompliantLazyFrame)CompliantExprAny)ExprMetadata)IntoArrowTable)EagerAllowedIntoBackendLazyAllowed
PluginNamePolars)GroupByLazyGroupBy)AsofJoinStrategyIntoDataFrame	IntoDTypeIntoExpr	IntoFrameIntoLazyFrame
IntoSchemaJoinStrategyMultiColSelectorMultiIndexSelectorPivotAggSingleColSelectorSingleIndexSelectorSizeUnitUniqueKeepStrategy_2DArrayPSrB   
Incomplete_FrameTrU   )bound
LazyFrameTrV   
DataFrameTrR   Rz_MultiColSelector[Series[Any]]rY   z _MultiIndexSelector[Series[Any]]rZ   c                  f   \ rS rSr% S\S'   S\S'   \" 5       rS\S'    \\S*S j5       5       r	S+S	 jr
S*S
 jrS,S jr      S-S jrS.S jrS/S jr\S0S j5       r\S1S j5       rS1S jr        S2S jrS3S jr\S4S j5       r      S5S jr      S5S jrS6S jrS7S jrS7S jrS8S jr      S9S jrSSS.         S:S jjrSS.       S;S  jjr              S<S! jrS=S>S" jjr                     S?S# jr!          S@S$ jr"SAS% jr#SAS& jr$SBS' jr%S(r&g))C	BaseFramer   r   _compliant_frame&Literal['full', 'lazy', 'interchange']_levelr   implementationc                    g N selfs    N/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/narwhals/dataframe.py
_compliantBaseFrame._compliant   s    !$    c                6    U R                   R                  5       $ rp   )rk   __native_namespace__rr   s    rt   ry   BaseFrame.__native_namespace__   s    $$99;;rw   c                6    U R                   R                  5       $ rp   )rk   __narwhals_namespace__rr   s    rt   r|    BaseFrame.__narwhals_namespace__   s    $$;;==rw   c                4    U R                  XR                  S9$ )Nlevel)	__class__rm   )rs   dfs     rt   _with_compliantBaseFrame._with_compliant   s    ~~b~44rw   c                l  ^ / nU R                  5       n[        [        U R                  R                  SS9m[        U4S j[        U5       5       U4S jUR                  5        5       5      nU H@  nUR                  U5      nUR                  U5        U R                  UR                  5        MB     U$ )NF)backendallow_literalc              3  4   >#    U  H  nT" U5      v   M     g 7frp   rq   ).0xparses     rt   	<genexpr>1BaseFrame._flatten_and_extract.<locals>.<genexpr>   s     .~!U1XX~s   c              3  V   >#    U  H  u  pT" U5      R                  U5      v   M      g 7frp   )alias)r   r   exprr   s      rt   r   r      s'     M9L+%U4[u%%9Ls   &))r|   r   r   ru   _implementationr   r   items_to_compliant_exprappend_validate_metadata	_metadata)	rs   exprsnamed_exprs	out_exprsns	all_exprsr   cer   s	           @rt   _flatten_and_extractBaseFrame._flatten_and_extract   s    
 	((*doo&E&EUZ
 .wu~.M9J9J9LM
	 D((,BR ##BLL1  rw   c                   [        U[        U 5      5      (       a  UR                  $ S[        U 5      < S[        U5      < 3n[	        U5      e)NzExpected `other` to be a , got: )
isinstancetyperk   r+   	TypeErrorrs   othermsgs      rt   _extract_compliant_frame"BaseFrame._extract_compliant_frame   sJ    eT$Z(())))*=d*C)FgNabgNhMklnrw   c                (    [        XR                  S9$ )N)	available)r   columnsrs   subsets     rt   _check_columns_existBaseFrame._check_columns_exist   s    "6\\BBrw   c                    g rp   rq   rs   metadatas     rt   r   BaseFrame._validate_metadata       rw   c                \    [        U R                  R                  R                  5       5      $ rp   )r4   rk   schemar   rr   s    rt   r   BaseFrame.schema   s"    d++2288:;;rw   c                H    [        U R                  R                  5       5      $ rp   )r4   rk   collect_schemarr   s    rt   r   BaseFrame.collect_schema   s    d++::<==rw   c                    U" U /UQ70 UD6$ rp   rq   )rs   functionargskwargss       rt   pipeBaseFrame.pipe   s     .t.v..rw   c                    [        U[        5      (       a  U/OUnU R                  U R                  R	                  US95      $ )Nr   )r   strr   rk   
drop_nullsr   s     rt   r   BaseFrame.drop_nulls   s<    '44&&##D$9$9$D$DF$D$STTrw   c                .    U R                   R                  $ rp   )rk   r   rr   s    rt   r   BaseFrame.columns   s    $$,,,rw   c                    U R                   " U0 UD6nU Vs/ s H%  n[        U5      (       a  UR                  5       OUPM'     nnU R                  U R                  R
                  " U6 5      $ s  snf rp   )r   r   	broadcastr   rk   with_columns)rs   r   r   compliant_exprscompliant_exprs        rt   r   BaseFrame.with_columns   s     33UJkJ
 #2	
 #2 n-- $$&  #2	 	 
 ##D$9$9$F$F$XYY
s   ,A-c                   [        [        U5      5      nU(       aG  [        S U 5       5      (       a0  U(       d)   U R                  U R                  R
                  " U6 5      $ U R                  " U0 UD6nU(       a?  [        S U 5       5      (       a(  U R                  U R                  R                  " U6 5      $ U Vs/ s H%  n[        U5      (       a  UR                  5       OUPM'     nnU R                  U R                  R                  " U6 5      $ ! [         a   nU R                  U5      =n(       a  XTee S nAff = fs  snf )Nc              3  B   #    U  H  n[        U[        5      v   M     g 7frp   r   r   r   r   s     rt   r   #BaseFrame.select.<locals>.<genexpr>   s     E*QjC00*   c              3  8   #    U  H  n[        U5      v   M     g 7frp   )r   r   s     rt   r   r      s     "No>!#4#4os   )tupler   allr   rk   simple_select	Exceptionr   r   	aggregater   r   select)rs   r   r   
flat_exprseerrorr   r   s           rt   r   BaseFrame.select   s<    75>*
#E*EEEk++))77D  33ZO;Os"No"NNN''(=(=(G(G(YZZ
 #2	
 #2 n-- $$&  #2	 	 
 ##D$9$9$@$@/$RSS   55jAA5A&	
s   'D ?,E
D?D::D?c                V    U R                  U R                  R                  U5      5      $ rp   )r   rk   rename)rs   mappings     rt   r   BaseFrame.rename   s$    ##D$9$9$@$@$IJJrw   c                V    U R                  U R                  R                  U5      5      $ rp   )r   rk   headrs   ns     rt   r   BaseFrame.head   $    ##D$9$9$>$>q$ABBrw   c                V    U R                  U R                  R                  U5      5      $ rp   )r   rk   tailr   s     rt   r   BaseFrame.tail   r   rw   c               R    U R                  U R                  R                  X!S95      $ )Nstrict)r   rk   drop)rs   r   r   s      rt   r   BaseFrame.drop   s'    ##D$9$9$>$>w$>$VWWrw   c                  ^ SSK JnJm  [        U5      nU" [	        UU4S jUR                  5        5       5      SS06nU R                  U5      u  n[        USS9  U R                  U R                  R                  U5      5      $ )Nr   )all_horizontalcolc              3  >   >#    U  H  u  pT" U5      U:H  v   M     g 7frp   rq   )r   namevr   s      rt   r   #BaseFrame.filter.<locals>.<genexpr>
  s     $WCVSY!^CVs   ignore_nullsFfilter)function_name)narwhals.functionsr   r   r   r   r   r   r   r   rk   r   )rs   
predicatesconstraintsr   flat_predicates	predicatecompliant_predicater   s          @rt   r   BaseFrame.filter  s     	;!*-"?$W;CTCTCV$WX

	 "&!:!:9!E	)*=XV##D$9$9$@$@AT$UVVrw   F
descending
nulls_lastc                   [        / [        U/5      QUQ5      nU R                  U R                  R                  " XUS.65      $ )Nr  )r   r   rk   sort)rs   byr  r  more_bys        rt   r  BaseFrame.sort  sH     /wt}/w/0##!!&&jY
 	
rw   reversec               l    [        U/5      nU R                  U R                  R                  XUS95      $ )Nr  r  )r   r   rk   top_k)rs   kr  r  
flatten_bys        rt   r  BaseFrame.top_k  s;     bT]
##!!''''J
 	
rw   c                  Sn[        U[        5      (       a  U/OUn[        U[        5      (       a  U/OUn[        U[        5      (       a  U/OUnU R                  nU R                  U5      nX7;  a  SU SU S3n	[	        U	5      eUS:X  a)  Uc  Uc  Ub  Sn	[        U	5      eUR                  XS S US9n
OyUcN  Ub  Uc  SU S	3n	[        U	5      e[        U5      [        U5      :w  a  S
n	[        U	5      eUR                  XXEUS9n
O(Uc  Ub  SU S	3n	[        U	5      eUR                  XX"US9n
U R                  U
5      $ )N)innerleftfullcrossantisemiz2Only the following join strategies are supported: 	; found ''.r  z>Can not pass `left_on`, `right_on` or `on` keys for cross join)howleft_onright_onsuffixzGEither (`left_on` and `right_on`) or `on` keys should be specified for .z3`left_on` and `right_on` must have the same length.zBIf `on` is specified, `left_on` and `right_on` should be None for )	r   r   rk   r   NotImplementedError
ValueErrorjoinlenr   )rs   r   onr  r  r  r  _supported_joins	compliantr   results              rt   r"  BaseFrame.join%  s    NC((bTb)'3777)W!+Hc!:!:H:))	--e4&FGWFXXabeaffhiC%c**'>"h&:bnV o%^^tF $ F Z("2_`c_ddef o%7|s8},K o%^^6 $ F "h&:Z[^Z__`a o%^^ $ F ##F++rw   c                R    U R                  U R                  R                  XS95      $ )Nr   offset)r   rk   gather_every)rs   r   r+  s      rt   r,  BaseFrame.gather_everyS  s,    ##!!...B
 	
rw   c                  Sn
X;  a  SU
 SU S3n[        U5      eUc  Ub  Uc  Sn[        U5      eUb  Uc  Ub  Sn[        U5      eUc  Uc  Uc  Ub  Uc  Sn[        U5      eUb  Uc  Ub  Sn[        U5      eUb  U=p#Ub  U=pV[        U[        5      (       a  U/OUn[        U[        5      (       a  U/OUn[        U[        5      (       a:  [        U[        5      (       a%  [        U5      [        U5      :w  a  S	n[        U5      eU R                  U R                  R                  U R                  U5      UUUUUU	S
95      $ )N)backwardforwardnearestz-Only the following strategies are supported: r  r  zCEither (`left_on` and `right_on`) or `on` keys should be specified.z>If `on` is specified, `left_on` and `right_on` should be None.zGCan not specify only `by_left` or `by_right`, you need to specify both.z>If `by` is specified, `by_left` and `by_right` should be None.z3`by_left` and `by_right` must have the same length.)r  r  by_leftby_rightstrategyr  )
r   r!  r   r   listr#  r   rk   	join_asofr   )rs   r   r  r  r$  r2  r3  r  r4  r  _supported_strategiesr   s               rt   r6  BaseFrame.join_asofX  s    !C0ABWAXXabjakkmnC%c**JW_0@WCS/!N!48LRCS/!J_!5#(8 Z  S/!N!48LRCS/!>!##G>!##G)'3777)W!+Hc!:!:H:w%%*Xt*D*DLCM)GCS/!##!!++--e4!!! , 

 
	
rw   c          	         [        U[        5      (       a  U/OUn[        U[        5      (       a  U/OUnU R                  U R                  R	                  XX4S95      $ )Nr$  indexvariable_name
value_name)r   r   r   rk   unpivot)rs   r$  r;  r<  r=  s        rt   r>  BaseFrame.unpivot  s_      C((bTb%eS11u##!!))- * 
 	
rw   c                    Sn[        U5      e)NzDataFrame.__neq__ and LazyFrame.__neq__ are not implemented, please use expressions instead.

Hint: instead of
    df != 0
you may want to use
    df.select(nw.all() != 0)r   r   s      rt   __neq__BaseFrame.__neq__      + 	 "#&&rw   c                    Sn[        U5      e)NzDataFrame.__eq__ and LazyFrame.__eq__ are not implemented, please use expressions instead.

Hint: instead of
    df == 0
you may want to use
    df.select(nw.all() == 0)rA  r   s      rt   __eq__BaseFrame.__eq__  rD  rw   c                    [        U[        5      (       a  U/UQO/ UQUQnU R                  U R                  R	                  US95      $ )Nr   )r   r   r   rk   explode)rs   r   more_columns
to_explodes       rt   rJ  BaseFrame.explode  sW     '3'' $|$*7*\* 	 ##D$9$9$A$A*$A$UVVrw   rq   N)returnr   )rN  r@   )r   r   rN  rD   )r   IntoExpr | Iterable[IntoExpr]r   rT   rN  zlist[CompliantExprAny])r   z
Self | AnyrN  r   )r   zSequence[str]rN  zColumnNotFoundError | Noner   rH   rN  NonerN  r4   r   z"Callable[Concatenate[Self, PS], R]r   zPS.argsr   z	PS.kwargsrN  rg   r   str | list[str] | NonerN  rD   rN  z	list[str]r   rO  r   rT   rN  rD   r   zdict[str, str]rN  rD   r   intrN  rD   )r   zIterable[str]r   boolrN  rD   r   rO  r   r   rN  rD   
r  str | Iterable[str]r  r   r  bool | Sequence[bool]r  r[  rN  rD   r  rZ  r  r^  r  r_  rN  rD   )r   rb   r$  rU  r  rX   r  rU  r  rU  r  r   rN  rD   r   r   rZ  r+  rZ  rN  rD   )r   rb   r  
str | Noner  rc  r$  rc  r2  rU  r3  rU  r  rU  r4  rQ   r  r   rN  rD   
r$  rU  r;  rU  r<  r   r=  r   rN  rD   )r   objectrN  r   r   str | Sequence[str]rK  r   rN  rD   )'__name__
__module____qualname____firstlineno____annotations__r   rn   propertyr   ru   ry   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r"  r,  r6  r>  rB  rF  rJ  __static_attributes__rq   rw   rt   ri   ri   r   s   22&5&7NO7( $  $<>53DL	(C   < <>/4/ / 	/
 
/U - -
Z3
ZDL
Z	
ZT3TDLT	T4KCCXW8WILW	W$ -2 



 

 *	


 

 


 TY

0
;P
	
,,,, #,, 	,, (,, ),, ,, 
,,\

<
<
 	<

 <
 <
 (<
 )<
 #<
 #<
 <
 
<
|
"
 &	

 
 
 

"	'	'Wrw   ri   c            	        ^  \ rS rSr% Sr\R                  rS\S'   \	SoS j5       r
\	SpS j5       r\	SqS j5       rSrS jrSsS	 jr\      StS
 j5       r\ SuSS.       SvS jjj5       r\ Su       SwS jj5       r\ Su       SxS jj5       rSyS jrSzS{S jjrS|S jrSuS}S jjr SuSS.     S~S jjjrSS jrSS jrSS jr\SuSS jj5       r\SS j5       rSuSS jjrSS jrSS jr\	SS j5       r SS jr!SSS  jjr"\SS! j5       r#\    SS" j5       r#\    SS# j5       r#    SS$ jr#SS% jr$\S&S'.SS( jj5       r%\SS) j5       r%\S*S'.   SS+ jj5       r%S*S'.   SS, jjr%SS- jr&        SU 4S. jjr'SuSU 4S/ jjjr( SSS0.     SS1 jjjr)\	SU 4S2 jj5       r*SU 4S3 jjr+\	SU 4S4 jj5       r,\S5S6.SS7 jj5       r-\SS8 j5       r-\SS9 j5       r-S5S6.   SS: jjr-SS; jr.\S&S&S<.     SS= jj5       r/\S&S>.     SS? jj5       r/\S&S>.     SS@ jj5       r/S5SAS<.     SSB jjr/      SU 4SC jjr0      SU 4SD jjr1SU 4SE jjr2SSU 4SF jjjr3SSU 4SG jjjr4S*SH.SU 4SI jjjr5 SuSJS5SSK.         SSL jjjr6      SU 4SM jjr7\S&SN.     SSO jj5       r8\      SSP j5       r8S5SN.     SSQ jjr8S5S5SR.         SU 4SS jjjr9S5ST.       SU 4SU jjjr:  SSSSVSW.             SU 4SX jjjjr;SSSSSSSYSVSZ.                   SU 4S[ jjjr<SS\ jr=SS] jr>SS^ jr?SS_ jr@SzSS` jjrASSa jrBSSU 4Sb jjjrCSSSSS5ScSd.               SSe jjrDSSf jrE SuSS5SSg.         SSh jjjrF SuSSiSjSk.         SU 4Sl jjjjrGSU 4Sm jjrHSnrIU =rJ$ )	DataFramei  a/  Narwhals DataFrame, backed by a native eager dataframe.

Warning:
    This class is not meant to be instantiated directly - instead:

    - If the native object is a eager dataframe from one of the supported
        backend (e.g. pandas.DataFrame, polars.DataFrame, pyarrow.Table),
        you can use [`narwhals.from_native`][]:
        ```py
        narwhals.from_native(native_dataframe)
        narwhals.from_native(native_dataframe, eager_only=True)
        ```

    - If the object is a dictionary of column names and generic sequences mapping
        (e.g. `dict[str, list]`), you can create a DataFrame via
        [`narwhals.from_dict`][]:
        ```py
        narwhals.from_dict(
            data={"a": [1, 2, 3]},
            backend=narwhals.get_native_namespace(another_object),
        )
        ```
ClassVar[Version]_versionc                    U R                   $ rp   rk   rr   s    rt   ru   DataFrame._compliant      $$$rw   c                    [         $ rp   r5   rr   s    rt   _seriesDataFrame._series  s    rw   c                    [         $ rp   )	LazyFramerr   s    rt   
_lazyframeDataFrame._lazyframe      rw   c                    g rp   rq   r   s     rt   r   DataFrame._validate_metadata  r   rw   c                   X l         U   [        U5      (       a  UR                  5       U l        g S[	        U5       3n[        U5      e)NzCExpected an object which implements `__narwhals_dataframe__`, got: )rm   r    __narwhals_dataframe__rk   r   AssertionErrorrs   r   r   r   s       rt   __init__DataFrame.__init__  sE    >C!"%%$&$=$=$?D!WX\]_X`WabC %%rw   c                  [        U5      (       d*  [        U5      (       d  S[        U5       S3n[        U5      e[        R
                  " U5      n[        U5      (       aO  U R                  R                  R                  U5      R                  nUR                  R                  XS9nU " USS9$ U SU S3n[        U5      e)u  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`.

Examples:
    >>> import pandas as pd
    >>> import polars as pl
    >>> import narwhals as nw
    >>>
    >>> df_native = pd.DataFrame({"a": [1, 2], "b": [4.2, 5.1]})
    >>> nw.DataFrame.from_arrow(df_native, backend="polars")
    ┌──────────────────┐
    |Narwhals DataFrame|
    |------------------|
    |  shape: (2, 2)   |
    |  ┌─────┬─────┐   |
    |  │ a   ┆ b   │   |
    |  │ --- ┆ --- │   |
    |  │ i64 ┆ f64 │   |
    |  ╞═════╪═════╡   |
    |  │ 1   ┆ 4.2 │   |
    |  │ 2   ┆ 5.1 │   |
    |  └─────┴─────┘   |
    └──────────────────┘
zGiven object of type z% does not support PyCapsule interface)contextr  r   z support in Narwhals is lazy-only, but `DataFrame.from_arrow` is an eager-only function.

Hint: you may want to use an eager backend and then call `.lazy`, e.g.:

    nw.DataFrame.from_arrow(df, backend='pyarrow').lazy(''))r,   r.   r   r   r   from_backendr"   rr  	namespacer&  
_dataframe
from_arrowr!  )clsnative_framer   r   rn   r   r&  s          rt   r  DataFrame.from_arrow  s    R (559I,9W9W)$|*<)==bcCC. '44W=N++''44^DNNB000JIy// HHVGWWY[ 	
 orw   Nr   c               T   Uc  [        U5      u  pUb  [        U5      OSn[        R                  " U5      n[	        U5      (       aP  U R
                  R                  R                  U5      R                  nUR                  R                  XUS9nU " USS9$ U SU S3n[        U5      e)u  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, dict of {name: type}, or a
        iterable of (name, type) tuples.
        If not specified, the schema will be inferred by the native library.
        If any `dtype` is `None`, the data type for that column will be
        inferred by the native library.
    backend: specifies which eager backend instantiate to. Only
        necessary if inputs are not Narwhals Series.

        `backend` can be specified in various ways

        - As `Implementation.<BACKEND>` with `BACKEND` being `PANDAS`, `PYARROW`,
            `POLARS`, `MODIN` or `CUDF`.
        - As a string: `"pandas"`, `"pyarrow"`, `"polars"`, `"modin"` or `"cudf"`.
        - Directly as a module `pandas`, `pyarrow`, `polars`, `modin` or `cudf`.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> data = {"c": [5, 2], "d": [1, 4]}
    >>> nw.DataFrame.from_dict(data, backend="pandas")
    ┌──────────────────┐
    |Narwhals DataFrame|
    |------------------|
    |        c  d      |
    |     0  5  1      |
    |     1  2  4      |
    └──────────────────┘
Nr   r  r  r   z support in Narwhals is lazy-only, but `DataFrame.from_dict` is an eager-only function.

Hint: you may want to use an eager backend and then call `.lazy`, e.g.:

    nw.DataFrame.from_dict({'a': [1, 2]}, backend='pyarrow').lazy('r  )r2   dictr   r  r"   rr  r  r&  r  	from_dictr!  r  datar   r   rn   r   r&  r   s           rt   r  DataFrame.from_dict3  s    ^ ?1$7MD!'!3f'44W=N++''44^DNNB//R/PIy//  TTbScceg 	
 orw   c               4   Ub  [        U5      OSn[        R                  " U5      n[        U5      (       aP  U R                  R
                  R                  U5      R                  nUR                  R                  XUS9nU " USS9$ U SU S3n[        U5      e)u	  Instantiate DataFrame from a sequence of dictionaries representing rows.

Notes:
    Keys missing from some (or all) rows are filled with null.

    For pandas-like dataframes, conversion to schema is applied after dataframe
    creation. A `schema` requesting a dtype which cannot hold null values (e.g.
    `Int64` or `Boolean` with the default numpy dtypes) will therefore coerce or
    raise on those missing values.

Arguments:
    data: Sequence with dictionaries mapping column name to value.
    schema: The DataFrame schema as Schema, dict of {name: type}, or a
        iterable of (name, type) tuples.
        If not specified, the schema will be inferred by the native library.
        If any `dtype` is `None`, the data type for that column will be
        inferred by the native library.
    backend: Specifies which eager backend instantiate to.

        `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`.

Tip:
    If you expect non-uniform keys in `data`, consider passing `schema` for
    more consistent results, as **inference varies between backends**:

    - pandas uses all rows
    - polars uses the first 100 rows
    - pyarrow uses only the first row

Examples:
    >>> import polars as pl
    >>> import narwhals as nw
    >>> data = [
    ...     {"item": "apple", "weight": 80, "price": 0.60},
    ...     {"item": "egg", "weight": 55, "price": 0.40},
    ... ]
    >>> nw.DataFrame.from_dicts(data, backend="polars")
    ┌──────────────────────────┐
    |    Narwhals DataFrame    |
    |--------------------------|
    |shape: (2, 3)             |
    |┌───────┬────────┬───────┐|
    |│ item  ┆ weight ┆ price │|
    |│ ---   ┆ ---    ┆ ---   │|
    |│ str   ┆ i64    ┆ f64   │|
    |╞═══════╪════════╪═══════╡|
    |│ apple ┆ 80     ┆ 0.6   │|
    |│ egg   ┆ 55     ┆ 0.4   │|
    |└───────┴────────┴───────┘|
    └──────────────────────────┘
Nr  r  r   z support in Narwhals is lazy-only, but `DataFrame.from_dicts` is an eager-only function.

Hint: you may want to use an eager backend and then call `.lazy`, e.g.:

    nw.DataFrame.from_dicts([{'a': 1}, {'a': 2}], backend='pyarrow').lazy('r  )
r  r   r  r"   rr  r  r&  r  
from_dictsr!  r  s           rt   r  DataFrame.from_dictsr  s    @ "(!3f'44W=N++''44^DNNB00b0QIy//  ^^l]mmoq 	
 orw   c                  [        U5      (       d  Sn[        U5      e[        U5      (       d  S[        U5       S3n[	        U5      eUb   [        U[        5      (       d  [        U5      n[        R                  " U5      n[        U5      (       aE  U R                  R                  R                  U5      R                  nU " UR                  X5      SS9$ U SU S3n[        U5      e)u  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}, an iterable
        of (name, type) tuples, 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`.

Examples:
    >>> import numpy as np
    >>> import polars as pl
    >>> import narwhals as nw
    >>>
    >>> arr = np.array([[5, 2, 1], [1, 4, 3]])
    >>> schema = {"c": nw.Int16(), "d": nw.Float32(), "e": nw.Int8()}
    >>> nw.DataFrame.from_numpy(arr, schema=schema, backend="polars")
    ┌───────────────────┐
    |Narwhals DataFrame |
    |-------------------|
    |shape: (2, 3)      |
    |┌─────┬─────┬─────┐|
    |│ c   ┆ d   ┆ e   │|
    |│ --- ┆ --- ┆ --- │|
    |│ i16 ┆ f32 ┆ i8  │|
    |╞═════╪═════╪═════╡|
    |│ 5   ┆ 2.0 ┆ 1   │|
    |│ 1   ┆ 4.0 ┆ 3   │|
    |└─────┴─────┴─────┘|
    └───────────────────┘
z)`from_numpy` only accepts 2D numpy arraysz`schema` is expected to be one of the following types: Schema | Mapping[str, IntoDType] | Iterable[tuple[str, IntoDType]] | Sequence[str].
Got r  r  r   z support in Narwhals is lazy-only, but `DataFrame.from_numpy` is an eager-only function.

Hint: you may want to use an eager backend and then call `.lazy`, e.g.:

    nw.DataFrame.from_numpy(arr, backend='pyarrow').lazy('r  )r-   r!  r3   r   r   r(   r   r4   r   r  r"   rr  r  r&  
from_numpy)r  r  r   r   r   rn   r   s          rt   r  DataFrame.from_numpy  s    f !&&=CS/!v&&F|nA' 
 C. ."="=F^F'44W=N++''44^DNNBr}}T2&AA IIWHXXZ\ 	
 orw   c                6    U R                   R                  5       $ rp   )rk   __len__rr   s    rt   r  DataFrame.__len__
  s    $$,,..rw   c                4    U R                   R                  XS9$ )Ncopy)rk   	__array__)rs   dtyper  s      rt   r  DataFrame.__array__  s    $$..u.@@rw   c                R    [        SU R                  5       R                  5       5      $ )NzNarwhals DataFramer   r8   __repr__rr   s    rt   r  DataFrame.__repr__       14>>3C3L3L3NOOrw   c                   U R                   R                  n[        U5      (       a  UR                  US9$  [        R
                  R                  5       nUS:  a  S[        U5       3n[        U5      SeU R                  5       nUR                  US9$ ! [         a  nS[        U5       3n[        U5      UeSnAff = f)a@  Export a DataFrame via the Arrow PyCapsule Interface.

- if the underlying dataframe implements the interface, it'll return that
- else, it'll call `to_arrow` and then defer to PyArrow's implementation

See [PyCapsule Interface](https://arrow.apache.org/docs/dev/format/CDataInterface/PyCapsuleInterface.html)
for more.
)requested_schemazT'pyarrow>=14.0.0' is required for `DataFrame.__arrow_c_stream__` for object of type N)   r   )
rk   _native_framer,   __arrow_c_stream__r   PYARROW_backend_versionModuleNotFoundErrorr   to_arrow)rs   r  r  
pa_versionexcr   pa_tables          rt   r  DataFrame.__arrow_c_stream__  s     ,,::"<0022DT2UU	4'//@@BJ himnzi{h|}C%c*4==?**<L*MM # 	4himnzi{h|}C%c*3	4s   B 
B=B88B=sessionc                  U R                   R                  nUc  U R                  U" SUS9SS9$ [        R                  " U5      n[        U5      (       a  U R                  U" XBS9SS9$ S[        [        5       SU 3n[        U5      e)u#
  Restrict available API methods to lazy-only ones.

If `backend` is specified, then a conversion between different backends
might be triggered.

If a library does not support lazy execution and `backend` is not specified,
then this is will only restrict the API to lazy-only operations. This is useful
if you want to ensure that you write dataframe-agnostic code which all has
the possibility of running entirely lazily.

Note:
    If `backend` is spark-like, then a valid `session` is required.

    For instance:

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

    df.lazy(backend=nw.Implementation.SQLFRAME, session=DuckDBSession())
    ```

Arguments:
    backend: Which lazy backend collect to. This will be the underlying
        backend for the resulting Narwhals LazyFrame. If not specified, and the
        given library does not support lazy execution, then this will restrict
        the API to lazy-only operations.

        `backend` can be specified in various ways

        - As `Implementation.<BACKEND>` with `BACKEND` being `DASK`, `DUCKDB`,
            `IBIS` or `POLARS`.
        - As a string: `"dask"`, `"duckdb"`, `"ibis"` or `"polars"`
        - Directly as a module `dask.dataframe`, `duckdb`, `ibis` or `polars`.
    session: Session to be used if backend is spark-like.

Examples:
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame({"a": [1, 2], "b": [4, 6]})
    >>> df = nw.from_native(df_native)

    If we call `df.lazy`, we get a `narwhals.LazyFrame` backed by a Polars
    LazyFrame.

    >>> df.lazy()  # doctest: +SKIP
    ┌─────────────────────────────┐
    |     Narwhals LazyFrame      |
    |-----------------------------|
    |<LazyFrame at 0x7F52B9937230>|
    └─────────────────────────────┘

    We can also pass DuckDB as the backend, and then we'll get a
    `narwhals.LazyFrame` backed by a `duckdb.DuckDBPyRelation`.

    >>> df.lazy(backend=nw.Implementation.DUCKDB)
    ┌──────────────────┐
    |Narwhals LazyFrame|
    |------------------|
    |┌───────┬───────┐ |
    |│   a   │   b   │ |
    |│ int64 │ int64 │ |
    |├───────┼───────┤ |
    |│     1 │     4 │ |
    |│     2 │     6 │ |
    |└───────┴───────┘ |
    └──────────────────┘
Nr  lazyr   z(Not-supported backend.

Expected one of z or `None`, got )	rk   r  r|  r   r  r%   r   r   r!  )rs   r   r  r  lazy_backendr   s         rt   r  DataFrame.lazy*  s    T $$))???4g#>f?MM%227;<((??4#Ff?UU:8DT;U:VVfgsftuorw   c                .    U R                   R                  $ )a  Convert Narwhals DataFrame to native one.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame(
    ...     {"foo": [1, 2, 3], "bar": [6.0, 7.0, 8.0], "ham": ["a", "b", "c"]}
    ... )

    Calling `to_native` on a Narwhals DataFrame returns the native object:

    >>> nw.from_native(df_native).to_native()
       foo  bar ham
    0    1  6.0   a
    1    2  7.0   b
    2    3  8.0   c
)rk   r  rr   s    rt   r8   DataFrame.to_native}  s    $ $$222rw   c                6    U R                   R                  5       $ )a|  Convert this DataFrame to a pandas DataFrame.

Examples:
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame(
    ...     {"foo": [1, 2, 3], "bar": [6.0, 7.0, 8.0], "ham": ["a", "b", "c"]}
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.to_pandas()
       foo  bar ham
    0    1  6.0   a
    1    2  7.0   b
    2    3  8.0   c
)rk   	to_pandasrr   s    rt   r  DataFrame.to_pandas  s      $$..00rw   c                6    U R                   R                  5       $ )u  Convert this DataFrame to a polars DataFrame.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"foo": [1, 2], "bar": [6.0, 7.0]})
    >>> df = nw.from_native(df_native)
    >>> df.to_polars()
    shape: (2, 2)
    ┌─────┬─────┐
    │ foo ┆ bar │
    │ --- ┆ --- │
    │ i64 ┆ f64 │
    ╞═════╪═════╡
    │ 1   ┆ 6.0 │
    │ 2   ┆ 7.0 │
    └─────┴─────┘
)rk   	to_polarsrr   s    rt   r  DataFrame.to_polars  s    & $$..00rw   c                    g rp   rq   rs   files     rt   	write_csvDataFrame.write_csv  s    36rw   c                    g rp   rq   r  s     rt   r  r    s    =@rw   c                8    U R                   R                  U5      $ )a}  Write dataframe to comma-separated values (CSV) file.

Arguments:
    file: String, path object or file-like object to which the dataframe will be
        written. If None, the resulting csv format is returned as a string.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame(
    ...     {"foo": [1, 2, 3], "bar": [6.0, 7.0, 8.0], "ham": ["a", "b", "c"]}
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.write_csv()  # doctest: +SKIP
    'foo,bar,ham\n1,6.0,a\n2,7.0,b\n3,8.0,c\n'

    If we had passed a file name to `write_csv`, it would have been
    written to that file.
)rk   r  r  s     rt   r  r    s    ( $$..t44rw   c                :    U R                   R                  U5        g)av  Write dataframe to parquet file.

Arguments:
    file: String, path object or file-like object to which the dataframe will be
        written.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"foo": [1, 2], "bar": [6.0, 7.0]})
    >>> df = nw.from_native(df_native)
    >>> df.write_parquet("out.parquet")  # doctest:+SKIP
N)rk   write_parquetr  s     rt   r  DataFrame.write_parquet  s     	++D1rw   c                6    U R                   R                  SSS9$ )a!  Convert this DataFrame to a NumPy ndarray.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"foo": [1, 2], "bar": [6.5, 7.0]})
    >>> df = nw.from_native(df_native)
    >>> df.to_numpy()
    array([[1. , 6.5],
           [2. , 7. ]])
Nr  )rk   to_numpyrr   s    rt   r  DataFrame.to_numpy  s      $$--d->>rw   c                .    U R                   R                  $ )zGet the shape of the DataFrame.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"foo": [1, 2]})
    >>> df = nw.from_native(df_native)
    >>> df.shape
    (2, 1)
)rk   shaperr   s    rt   r  DataFrame.shape  s     $$***rw   c                h    U R                  U R                  R                  U5      U R                  S9$ )a  Get a single column by name.

Arguments:
    name: The column name as a string.

Notes:
    Although `name` is typed as `str`, pandas does allow non-string column
    names, and they will work when passed to this function if the
    `narwhals.DataFrame` is backed by a pandas dataframe with non-string
    columns. This function can only be used to extract a column by name, so
    there is no risk of ambiguity.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"a": [1, 2]})
    >>> df = nw.from_native(df_native)
    >>> df.get_column("a").to_native()
    0    1
    1    2
    Name: a, dtype: int64
r   )rx  rk   
get_columnrm   )rs   r   s     rt   r  DataFrame.get_column   s,    . ||D11<<TB$++|VVrw   c                4    U R                   R                  US9$ )a  Return an estimation of the total (heap) allocated size of the `DataFrame`.

Estimated size is given in the specified unit (bytes by default).

Arguments:
    unit: 'b', 'kb', 'mb', 'gb', 'tb', 'bytes', 'kilobytes', 'megabytes',
        'gigabytes', or 'terabytes'.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"foo": [1, 2], "bar": [6.0, 7.0]})
    >>> df = nw.from_native(df_native)
    >>> df.estimated_size()
    32
)unit)rk   estimated_size)rs   r  s     rt   r  DataFrame.estimated_size  s    " $$333>>rw   c                    g rp   rq   rs   items     rt   __getitem__DataFrame.__getitem__.  s    WZrw   c                    g rp   rq   r  s     rt   r  r  1  s     rw   c                    g rp   rq   r  s     rt   r  r  6  s     rw   c                r   SSK Jn  S[        U5       S3n[        U[        5      (       ao  [        U5      S:  a  Sn[        U5      eU(       a  [        US   5      (       a  SOUS   n[        U5      S:  d  [        US   5      (       a  SOUS   nUc  Uc  U $ OP[        U5      (       a  UnSnO;[        U5      (       d  [        U[        [        45      (       a  SnUnO[        U5      e[        U[        5      (       a  [        U5      eU R                  n[        U[        5      (       a  [        U5      e[        U[        [        45      (       af  [        U[        5      (       a  U R                  XV5      $ [        U[        5      (       a  UOU R                   U   nU R#                  U5      n	Ub  X   $ U	$ [        XR5      (       a  UR$                  n[        Xb5      (       a  UR$                  nUc  U R'                  USS2U4   5      $ Uc  U R'                  XuSS24   5      $ U R'                  XuU4   5      $ )	a  Extract column or slice of DataFrame.

Arguments:
    item: How to slice dataframe. What happens depends on what is passed. It's easiest
        to explain by example. Suppose we have a Dataframe `df`

        - `df['a']` extracts column `'a'` and returns a `Series`.
        - `df[0:2]` extracts the first two rows and returns a `DataFrame`.
        - `df[0:2, 'a']` extracts the first two rows from column `'a'` and returns
            a `Series`.
        - `df[0:2, 0]` extracts the first two rows from the first column and returns
            a `Series`.
        - `df[[0, 1], [0, 1, 2]]` extracts the first two rows and the first three columns
            and returns a `DataFrame`
        - `df[:, [0, 1, 2]]` extracts all rows from the first three columns and returns a
          `DataFrame`.
        - `df[:, ['a', 'c']]` extracts all rows and columns `'a'` and `'c'` and returns a
          `DataFrame`.
        - `df[:, [True, False, True]]` extracts all rows and columns in positions 0 and 2
          and returns a `DataFrame`.
        - `df[['a', 'c']]` extracts all rows and columns `'a'` and `'c'` and returns a
          `DataFrame`.
        - `df[0: 2, ['a', 'c']]` extracts the first two rows and columns `'a'` and `'c'` and
            returns a `DataFrame`
        - `df[:, 0: 2]` extracts all rows from the first two columns and returns a `DataFrame`
        - `df[:, 'a': 'c']` extracts all rows and all columns positioned between `'a'` and `'c'`
            _inclusive_ and returns a `DataFrame`. For example, if the columns are
            `'a', 'd', 'c', 'b'`, then that would extract columns `'a'`, `'d'`, and `'c'`.

Notes:
    - Integers are always interpreted as positions
    - Strings are always interpreted as column names.

    In contrast with Polars, pandas allows non-string column names.
    If you don't know whether the column name you're trying to extract
    is definitely a string (e.g. `df[df.columns[0]]`) then you should
    use `DataFrame.get_column` instead.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"a": [1, 2]})
    >>> df = nw.from_native(df_native)
    >>> df["a"].to_native()
    0    1
    1    2
    Name: a, dtype: int64
r   r5   z2Unexpected type for `DataFrame.__getitem__`, got: z.

Hints:
- use `df.item` to select a single item.
- Use `df[indices, :]` to select rows positionally.
- Use `df.filter(mask)` to filter rows based on a boolean mask.   zzTuples cannot be passed to DataFrame.__getitem__ directly.

Hint: instead of `df[indices]`, did you mean `df[indices, :]`?N   )narwhals.seriesr6   r   r   r   r#  r   r)   r#   r'   slicer   rk   r[  rZ  r  r   r  _compliant_seriesr   )
rs   r  r6   r   	tuple_msgrowsr   r&  col_nameseriess
             rt   r  r  A  s   z 	+ Ad MN N 	 dE""4y1}U   	**#}T!W'='=447D!$i!m}T!W/E/Ed4PQ7G|t$$DGd##z$'E'EDGC. dC  C. ))	gt$$C. gSz**$$$yy//",Wc":":wW@UH__X.F#'#36<??d##))Dg&&//G<''	!W*(=>>?''	'(:;;##IGm$<==rw   c                    XR                   ;   $ rp   rI  )rs   keys     rt   __contains__DataFrame.__contains__  s    ll""rw   .	as_seriesc                   g rp   rq   rs   r  s     rt   to_dictDataFrame.to_dict      TWrw   c                   g rp   rq   r  s     rt   r  r    s    MPrw   Tc                   g rp   rq   r  s     rt   r  r    s     9<rw   c          
         U(       aS  U R                   R                  US9R                  5        VVs0 s H  u  p#X R                  X0R                  S9_M      snn$ U R                   R                  US9$ s  snnf )a  Convert DataFrame to a dictionary mapping column name to values.

Arguments:
    as_series: If set to true ``True``, then the values are Narwhals Series,
            otherwise the values are Any.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"A": [1, 2], "fruits": ["banana", "apple"]})
    >>> df = nw.from_native(df_native)
    >>> df.to_dict(as_series=False)
    {'A': [1, 2], 'fruits': ['banana', 'apple']}
r  r   )rk   r  r   rx  rm   )rs   r  r  values       rt   r  r    s    "  #'"7"7"?"?' #@ #%'##JC \\%{{\;;#  $$,,y,AAs   %A4c                8    U R                   R                  U5      $ )a  Get values at given row.

Warning:
    You should NEVER use this method to iterate over a DataFrame;
    if you require row-iteration you should strongly prefer use of iter_rows()
    instead.

Arguments:
    index: Row number.

Notes:
    cuDF doesn't support this method.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"a": [1, 2], "b": [4, 5]})
    >>> nw.from_native(df_native).row(1)
    (2, 5)
)rk   row)rs   r;  s     rt   r   DataFrame.row  s    * $$((//rw   c                ,   > [         TU ]  " U/UQ70 UD6$ )a  Pipe function call.

Arguments:
    function: Function to apply.
    args: Positional arguments to pass to function.
    kwargs: Keyword arguments to pass to function.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"a": [1, 2], "ba": [4, 5]})
    >>> nw.from_native(df_native).pipe(
    ...     lambda _df: _df.select(
    ...         [x for x in _df.columns if len(x) == 1]
    ...     ).to_native()
    ... )
       a
    0  1
    1  2
superr   rs   r   r   r   r   s       rt   r   DataFrame.pipe  s    4 w|H6t6v66rw   c                   > [         TU ]  US9$ )aP  Drop rows that contain null values.

Arguments:
    subset: Column name(s) for which null values are considered. If set to None
        (default), use all columns.

Notes:
    pandas handles null values differently from Polars and PyArrow.
    See [null_handling](../concepts/null_handling.md)
    for reference.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"a": [1.0, None], "ba": [1.0, 2.0]})
    >>> nw.from_native(df_native).drop_nulls().to_native()
    pyarrow.Table
    a: double
    ba: double
    ----
    a: [[1]]
    ba: [[1]]
r   r  r   rs   r   r   s     rt   r   DataFrame.drop_nulls  s    0 w!!00rw   order_byc                   [        U[        5      (       a  U/OUnU R                  U R                  R	                  XS95      $ )a  Insert column which enumerates rows.

Arguments:
    name: The name of the column as a string. The default is "index".
    order_by: Column(s) to order by when computing the row index. Nulls are placed first.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"a": [1, 2], "b": [4, 5]})
    >>> nw.from_native(df_native).with_row_index().to_native()
    pyarrow.Table
    index: int64
    a: int64
    b: int64
    ----
    index: [[0,1]]
    a: [[1,2]]
    b: [[4,5]]
r  r   r   r   rk   with_row_indexrs   r   r  	order_by_s       rt   r  DataFrame.with_row_index&  sC    . #-Xs";";XJ	##!!000J
 	
rw   c                   > [         TU ]  $ )a  Get an ordered mapping of column names to their data type.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"foo": [1, 2], "bar": [6.0, 7.0]})
    >>> nw.from_native(df_native).schema
    Schema({'foo': Int64, 'bar': Float64})
)r  r   rs   r   s    rt   r   DataFrame.schemaB  s     w~rw   c                    > [         TU ]  5       $ )a   Get an ordered mapping of column names to their data type.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"foo": [1, 2], "bar": [6.0, 7.0]})
    >>> nw.from_native(df_native).collect_schema()
    Schema({'foo': Int64, 'bar': Float64})
r  r   r  s    rt   r   DataFrame.collect_schemaO       w%''rw   c                   > [         TU ]  $ )a  Get column names.

Note:
    The pandas-like and dask backends allow non-string column names
    (e.g. integers or booleans). While discouraged, this is supported,
    so the return type is not guaranteed to be `list[str]`.

    See [concepts - column names](../concepts/column_names.md) for details.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"foo": [1, 2], "bar": [6.0, 7.0]})
    >>> nw.from_native(df_native).columns
    ['foo', 'bar']
r  r   r  s    rt   r   DataFrame.columns[      $ wrw   Fnamedc                   g rp   rq   rs   r  s     rt   r  DataFrame.rowso  s    ORrw   c                   g rp   rq   r!  s     rt   r  r"  r  s    EHrw   c                   g rp   rq   r!  s     rt   r  r"  u  r  rw   c               4    U R                   R                  US9$ )a  Returns all data in the DataFrame as a list of rows of python-native values.

Arguments:
    named: By default, each row is returned as a tuple of values given
        in the same order as the frame columns. Setting named=True will
        return rows of dictionaries instead.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"foo": [1, 2], "bar": [6.0, 7.0]})
    >>> nw.from_native(df_native).rows()
    [(1, 6.0), (2, 7.0)]
r  )rk   r  r!  s     rt   r  r"  x  s    " $$)))66rw   c              #     #    U R                   R                  5        H  nU R                  XR                  S9v   M      g7f)u  Returns an iterator over the columns of this DataFrame.

Yields:
    A Narwhals Series, backed by a native series.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"foo": [1, 2], "bar": [6.0, 7.0]})
    >>> iter_columns = nw.from_native(df_native).iter_columns()
    >>> next(iter_columns)
    ┌───────────────────────┐
    |    Narwhals Series    |
    |-----------------------|
    |0    1                 |
    |1    2                 |
    |Name: foo, dtype: int64|
    └───────────────────────┘
    >>> next(iter_columns)
    ┌─────────────────────────┐
    |     Narwhals Series     |
    |-------------------------|
    |0    6.0                 |
    |1    7.0                 |
    |Name: bar, dtype: float64|
    └─────────────────────────┘
r   N)rk   iter_columnsrx  rm   )rs   r  s     rt   r'  DataFrame.iter_columns  s5     8 ++88:F,,v[[,99 ;s   >A r  buffer_sizec                   g rp   rq   rs   r  r*  s      rt   	iter_rowsDataFrame.iter_rows  s     %(rw   )r*  c                   g rp   rq   r,  s      rt   r-  r.    s     $'rw   c                   g rp   rq   r,  s      rt   r-  r.    s	     @Crw   i   c               4    U R                   R                  XS9$ )a'  Returns an iterator over the DataFrame of rows of python-native values.

Arguments:
    named: By default, each row is returned as a tuple of values given
        in the same order as the frame columns. Setting named=True will
        return rows of dictionaries instead.
    buffer_size: Determines the number of rows that are buffered
        internally while iterating over the data.
        See https://docs.pola.rs/api/python/stable/reference/dataframe/api/polars.DataFrame.iter_rows.html

Notes:
    cuDF doesn't support this method.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"foo": [1, 2], "bar": [6.0, 7.0]})
    >>> iter_rows = nw.from_native(df_native).iter_rows()
    >>> next(iter_rows)
    (1, 6.0)
    >>> next(iter_rows)
    (2, 7.0)
r)  )rk   r-  r,  s      rt   r-  r.    s    4 $$..U.TTrw   c                $   > [         TU ]  " U0 UD6$ )a  Add columns to this DataFrame.

Added columns will replace existing columns with the same name.

Arguments:
    *exprs: Column(s) to add, specified as positional arguments.
             Accepts expression input. Strings are parsed as column names, other
             non-expression inputs are parsed as literals.

    **named_exprs: Additional columns to add, specified as keyword arguments.
                    The columns will be renamed to the keyword used.

Note:
    Creating a new DataFrame using this method does not create a new copy of
    existing data.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"a": [1, 2], "b": [0.5, 4.0]})
    >>> (
    ...     nw.from_native(df_native)
    ...     .with_columns((nw.col("a") * 2).alias("a*2"))
    ...     .to_native()
    ... )
       a    b  a*2
    0  1  0.5    2
    1  2  4.0    4
)r  r   rs   r   r   r   s      rt   r   DataFrame.with_columns  s    @ w#U:k::rw   c                $   > [         TU ]  " U0 UD6$ )u  Select columns from this DataFrame.

Arguments:
    *exprs: Column(s) to select, specified as positional arguments.
             Accepts expression input. Strings are parsed as column names,
             other non-expression inputs are parsed as literals.

    **named_exprs: Additional columns to select, specified as keyword arguments.
                    The columns will be renamed to the keyword used.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"a": [1, 2], "b": [3, 4]})
    >>> nw.from_native(df_native).select("a", a_plus_1=nw.col("a") + 1)
    ┌──────────────────┐
    |Narwhals DataFrame|
    |------------------|
    |pyarrow.Table     |
    |a: int64          |
    |a_plus_1: int64   |
    |----              |
    |a: [[1,2]]        |
    |a_plus_1: [[2,3]] |
    └──────────────────┘
)r  r   r3  s      rt   r   DataFrame.select  s    : w~u444rw   c                "   > [         TU ]  U5      $ )a  Rename column names.

Arguments:
    mapping: Key value pairs that map from old name to new name.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"foo": [1, 2], "bar": [6, 7]})
    >>> nw.from_native(df_native).rename({"foo": "apple"}).to_native()
    pyarrow.Table
    apple: int64
    bar: int64
    ----
    apple: [[1,2]]
    bar: [[6,7]]
r  r   rs   r   r   s     rt   r   DataFrame.rename  s    $ w~g&&rw   c                "   > [         TU ]  U5      $ )an  Get the first `n` rows.

Arguments:
    n: Number of rows to return. If a negative value is passed, return all rows
        except the last `abs(n)`.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"a": [1, 2], "b": [0.5, 4.0]})
    >>> nw.from_native(df_native).head(1).to_native()
       a    b
    0  1  0.5
r  r   rs   r   r   s     rt   r   DataFrame.head*  s     w|Arw   c                "   > [         TU ]  U5      $ )u,  Get the last `n` rows.

Arguments:
    n: Number of rows to return. If a negative value is passed, return all rows
        except the first `abs(n)`.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"a": [1, 2], "b": [0.5, 4.0]})
    >>> nw.from_native(df_native).tail(1)
    ┌──────────────────┐
    |Narwhals DataFrame|
    |------------------|
    |       a    b     |
    |    1  2  4.0     |
    └──────────────────┘
)r  r   r=  s     rt   r   DataFrame.tail;      & w|Arw   r   c               6   > [         TU ]  " [        U5      SU06$ )a'  Remove columns from the dataframe.

Arguments:
    *columns: Names of the columns that should be removed from the dataframe.
    strict: Validate that all column names exist in the schema and throw an
        exception if a column name does not exist in the schema.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame(
    ...     {"foo": [1, 2], "bar": [6.0, 7.0], "ham": ["a", "b"]}
    ... )
    >>> nw.from_native(df_native).drop("ham").to_native()
       foo  bar
    0    1  6.0
    1    2  7.0
r   r  r   r   rs   r   r   r   s      rt   r   DataFrame.dropP  s    & w|WW-=f==rw   anykeepmaintain_orderr  c          	         US;  a  SS SU 3n[        U5      e[        U[        5      (       a  U/nU R                  U R                  R                  XX4S95      $ )a  Drop duplicate rows from this dataframe.

Arguments:
    subset: Column name(s) to consider when identifying duplicate rows.
    keep: {'first', 'last', 'any', 'none'}
        Which of the duplicate rows to keep.

        * 'any': Does not give any guarantee of which row is kept.
                This allows more optimizations.
        * 'none': Don't keep duplicate rows.
        * 'first': Keep first unique row.
        * 'last': Keep last unique row.
    maintain_order: Keep the same order as the original DataFrame. This may be more
        expensive to compute.
    order_by: Column(s) to order by when computing the row index. Nulls are placed first.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame(
    ...     {"foo": [1, 2], "bar": ["a", "a"], "ham": ["b", "b"]}
    ... )
    >>> nw.from_native(df_native).unique(["bar", "ham"]).to_native()
       foo bar ham
    0    1   a   b
>   rF  lastnonefirst	Expected rF  rL  rM  rK  r   rG  )r!  r   r   r   rk   unique)rs   r   rH  rI  r  r   s         rt   rP  DataFrame.uniquee  sq    D 77<=WTFKCS/!fc""XF##!!((. ) 
 	
rw   c                Z   >^ ^ T R                   mUU 4S jU 5       n[        TT ]  " U0 UD6$ )a  Filter the rows in the DataFrame based on one or more predicate expressions.

The original order of the remaining rows is preserved.

Arguments:
    *predicates: Expression(s) that evaluates to a boolean Series. Can
        also be a boolean list(s).
    **constraints: Column filters; use `name = value` to filter columns by the supplied value.
        Each constraint will behave the same as `nw.col(name).eq(value)`, and will be implicitly
        joined with the other filter conditions using &.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame(
    ...     {"foo": [1, 2, 3], "bar": [6, 7, 8], "ham": ["a", "b", "c"]}
    ... )

    Filter on one condition

    >>> nw.from_native(df_native).filter(nw.col("foo") > 1).to_native()
       foo  bar ham
    1    2    7   b
    2    3    8   c

    Filter on multiple conditions with implicit `&`

    >>> nw.from_native(df_native).filter(
    ...     nw.col("foo") < 3, nw.col("ham") == "a"
    ... ).to_native()
       foo  bar ham
    0    1    6   a

    Filter on multiple conditions with `|`

    >>> nw.from_native(df_native).filter(
    ...     (nw.col("foo") == 1) | (nw.col("ham") == "c")
    ... ).to_native()
       foo  bar ham
    0    1    6   a
    2    3    8   c

    Filter using `**kwargs` syntax

    >>> nw.from_native(df_native).filter(foo=2, ham="b").to_native()
       foo  bar ham
    1    2    7   b
c              3     >#    U  H7  n[        U[        5      (       a  TR                  R                  S UTS9OUv   M9     g7f) r  N)r&   r[  rx  from_iterable)r   pimplrs   s     rt   r   #DataFrame.filter.<locals>.<genexpr>  sB      
 @J!T?R?RDLL&&r1d&;XYYs   ?A)rn   r  r   )rs   r   r   parsed_predicatesrW  r   s   `   @rt   r   DataFrame.filter  s8    f ""

 w~0@K@@rw   drop_null_keysc                   g rp   rq   rs   r\  keyss      rt   group_byDataFrame.group_by       rw   c                   g rp   rq   r^  s      rt   r`  ra    rb  rw   c                 ^^ SSK Jn  [        U5      n[        S U 5       5      (       a  U" XUS9$ SSKJn  SSKJm  SSKJ	m  [        UU4S jU 5       5      nU(       a  [        U5      (       a  S	n[        U5      e[        XFS
S9 VV	s/ s H  u  pU	(       a  UOU" U5      PM     n
nn	U R                  " U
6 n[        USS06  U" XUS9$ s  sn	nf )a<  Start a group by operation.

Arguments:
    *keys: Column(s) to group by. Accepts expression input. Strings are parsed as
        column names.
    drop_null_keys: if True, then groups where any key is null won't be included
        in the result.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame(
    ...     {
    ...         "a": ["a", "b", "a", "b", "c"],
    ...         "b": [1, 2, 1, 3, 3],
    ...         "c": [5, 4, 3, 2, 1],
    ...     }
    ... )

    Group by one column and compute the sum of another column

    >>> nw.from_native(df_native, eager_only=True).group_by("a").agg(
    ...     nw.col("b").sum()
    ... ).sort("a").to_native()
       a  b
    0  a  2
    1  b  5
    2  c  3

    Group by multiple columns and compute the max of another column

    >>> (
    ...     nw.from_native(df_native, eager_only=True)
    ...     .group_by(["a", "b"])
    ...     .agg(nw.max("c"))
    ...     .sort("a", "b")
    ...     .to_native()
    ... )
       a  b  c
    0  a  1  5
    1  b  2  4
    2  b  3  2
    3  c  3  1

    Expressions are also accepted.

    >>> nw.from_native(df_native, eager_only=True).group_by(
    ...     "a", nw.col("b") // 2
    ... ).agg(nw.col("c").mean()).to_native()
       a  b    c
    0  a  0  4.0
    1  b  1  3.0
    2  c  1  1.0
r   )rO   c              3  B   #    U  H  n[        U[        5      v   M     g 7frp   r   r   r  s     rt   r   %DataFrame.group_by.<locals>.<genexpr>       9yz#s##yr   r[  r   Exprr5   c              3  @   >#    U  H  n[        UTT45      v   M     g 7frp   r   )r   r  rk  r6   s     rt   r   rg    s     %WYjT6N&C&CYs   z?drop_null_keys cannot be True when keys contains Expr or SeriesTr   r   zDataFrame.group_by)narwhals.group_byrO   r   r   narwhalsr   narwhals.exprrk  r  r6   r   rF  r   zipr   r   )rs   r\  r_  rO   	flat_keysr   key_is_expr_or_seriesr   r  is_expr_keysexpr_flat_keysrk  r6   s               @@rt   r`  ra    s    r 	.DM	9y9994>JJ &* %%WY%W Wc"788SC%c** ")4P
P
 Ac!f$P 	 
 22E:)	
+?	
 tNKK
s   Cr  c               ,   > [         TU ]  " U/UQ7X#S.6$ )u  Sort the dataframe by the given columns.

Arguments:
    by: Column(s) names to sort by.
    *more_by: Additional columns to sort by, specified as positional arguments.
    descending: Sort in descending order. When sorting by multiple columns, can be
        specified per column by passing a sequence of booleans.
    nulls_last: Place null values last.

Note:
    Unlike Polars, it is not possible to specify a sequence of booleans for
    `nulls_last` in order to control per-column behaviour. Instead a single
    boolean is applied for all `by` columns.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame(
    ...     {"foo": [2, 1], "bar": [6.0, 7.0], "ham": ["a", "b"]}
    ... )
    >>> nw.from_native(df_native).sort("foo")
    ┌──────────────────┐
    |Narwhals DataFrame|
    |------------------|
    |    foo  bar ham  |
    | 1    1  7.0   b  |
    | 0    2  6.0   a  |
    └──────────────────┘
r  r  r  rs   r  r  r  r  r   s        rt   r  DataFrame.sort*  s    H w|BWWZWWrw   r
  c                   > [         TU ]  XUS9$ )ui  Return the `k` largest rows.

Non-null elements are always preferred over null elements,
regardless of the value of reverse. The output is not guaranteed
to be in any particular order, sort the outputs afterwards if you wish the output to be sorted.

Arguments:
    k: Number of rows to return.
    by: Column(s) used to determine the top rows. Accepts expression input. Strings are parsed as column names.
    reverse: Consider the k smallest elements of the by column(s) (instead of the k largest).
        This can be specified per column by passing a sequence of booleans.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame(
    ...     {"a": ["a", "b", "a", "b", None, "c"], "b": [2, 1, 1, 3, 2, 1]}
    ... )
    >>> nw.from_native(df_native).top_k(4, by=["b", "a"])
    ┌──────────────────┐
    |Narwhals DataFrame|
    |------------------|
    |         a  b     |
    |    3    b  3     |
    |    0    a  2     |
    |    4  NaN  2     |
    |    5    c  1     |
    └──────────────────┘
r  r  r  rs   r  r  r  r   s       rt   r  DataFrame.top_kP  s    @ w}Qw}77rw   _rightr  r  r  c          	     "   > [         TU ]  XXEX&S9$ )u  Join in SQL-like fashion.

Arguments:
    other: DataFrame to join with.
    on: Name(s) of the join columns in both DataFrames. If set, `left_on` and
        `right_on` should be None.
    how: Join strategy.

          * *inner*: Returns rows that have matching values in both tables.
          * *left*: Returns all rows from the left table, and the matched rows from the right table.
          * *full*: Returns all rows in both dataframes, with the suffix appended to the right join keys.
          * *cross*: Returns the Cartesian product of rows from both tables.
          * *semi*: Filter rows that have a match in the right table.
          * *anti*: Filter rows that do not have a match in the right table.
    left_on: Join column of the left DataFrame.
    right_on: Join column of the right DataFrame.
    suffix: Suffix to append to columns with a duplicate name.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_1_native = pd.DataFrame({"id": ["a", "b"], "price": [6.0, 7.0]})
    >>> df_2_native = pd.DataFrame({"id": ["a", "b", "c"], "qty": [1, 2, 3]})
    >>> nw.from_native(df_1_native).join(nw.from_native(df_2_native), on="id")
    ┌──────────────────┐
    |Narwhals DataFrame|
    |------------------|
    |   id  price  qty |
    | 0  a    6.0    1 |
    | 1  b    7.0    2 |
    └──────────────────┘
r  r  r  r$  r  r  r"  rs   r   r$  r  r  r  r  r   s          rt   r"  DataFrame.joinr  s#    T w|G2  
 	
rw   r/  r  r  r$  r2  r3  r  r4  r  c               .   > [         T
U ]  UUUUUUUUU	S9	$ )u	  Perform an asof join.

This is similar to a left-join except that we match on nearest key rather than equal keys.

For Polars, both DataFrames must be sorted by the `on` key (within each `by` group
if specified).

Arguments:
    other: DataFrame to join with.
    left_on: Name(s) of the left join column(s).
    right_on: Name(s) of the right join column(s).
    on: Join column of both DataFrames. If set, left_on and right_on should be None.
    by_left: join on these columns before doing asof join.
    by_right: join on these columns before doing asof join.
    by: join on these columns before doing asof join.
    strategy: Join strategy. The default is "backward".
    suffix: Suffix to append to columns with a duplicate name.

          * *backward*: selects the last row in the right DataFrame whose "on" key is less than or equal to the left's key.
          * *forward*: selects the first row in the right DataFrame whose "on" key is greater than or equal to the left's key.
          * *nearest*: search selects the last row in the right DataFrame whose value is nearest to the left's key.

Examples:
    >>> from datetime import datetime
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> data_gdp = {
    ...     "datetime": [
    ...         datetime(2016, 1, 1),
    ...         datetime(2017, 1, 1),
    ...         datetime(2018, 1, 1),
    ...         datetime(2019, 1, 1),
    ...         datetime(2020, 1, 1),
    ...     ],
    ...     "gdp": [4164, 4411, 4566, 4696, 4827],
    ... }
    >>> data_population = {
    ...     "datetime": [
    ...         datetime(2016, 3, 1),
    ...         datetime(2018, 8, 1),
    ...         datetime(2019, 1, 1),
    ...     ],
    ...     "population": [82.19, 82.66, 83.12],
    ... }
    >>> gdp_native = pd.DataFrame(data_gdp)
    >>> population_native = pd.DataFrame(data_population)
    >>> gdp = nw.from_native(gdp_native)
    >>> population = nw.from_native(population_native)
    >>> population.join_asof(gdp, on="datetime", strategy="backward")
    ┌──────────────────────────────┐
    |      Narwhals DataFrame      |
    |------------------------------|
    |    datetime  population   gdp|
    |0 2016-03-01       82.19  4164|
    |1 2018-08-01       82.66  4566|
    |2 2019-01-01       83.12  4696|
    └──────────────────────────────┘
r  r  r6  rs   r   r  r  r$  r2  r3  r  r4  r  r   s             rt   r6  DataFrame.join_asof  s8    N w  ! 

 
	
rw   c                $    U R                  5       ) $ )u  Get a mask of all duplicated rows in this DataFrame.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"foo": [2, 2, 2], "bar": [6.0, 6.0, 7.0]})
    >>> nw.from_native(df_native).is_duplicated()
    ┌───────────────┐
    |Narwhals Series|
    |---------------|
    |  0     True   |
    |  1     True   |
    |  2    False   |
    |  dtype: bool  |
    └───────────────┘
)	is_uniquerr   s    rt   is_duplicatedDataFrame.is_duplicated  s    "    rw   c                    [        U 5      S:H  $ )zCheck if the dataframe is empty.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"foo": [2, 2, 2], "bar": [6.0, 6.0, 7.0]})
    >>> nw.from_native(df_native).is_empty()
    False
r   )r#  rr   s    rt   is_emptyDataFrame.is_empty  s     4yA~rw   c                f    U R                  U R                  R                  5       U R                  S9$ )u  Get a mask of all unique rows in this DataFrame.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"foo": [2, 2, 2], "bar": [6.0, 6.0, 7.0]})
    >>> nw.from_native(df_native).is_unique()
    ┌───────────────┐
    |Narwhals Series|
    |---------------|
    |  0    False   |
    |  1    False   |
    |  2     True   |
    |  dtype: bool  |
    └───────────────┘
r   )rx  rk   r  rm   rr   s    rt   r  DataFrame.is_unique  s*    " ||D11;;=T[[|QQrw   c                    U R                   R                  5       nU R                   R                  UR                  5       R	                  5       5      nU R                  U5      $ )u  Create a new DataFrame that shows the null counts per column.

Notes:
    pandas handles null values differently from Polars and PyArrow.
    See [null_handling](../concepts/null_handling.md) for reference.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"foo": [1, None], "bar": [2, 3]})
    >>> nw.from_native(df_native).null_count()
    ┌──────────────────┐
    |Narwhals DataFrame|
    |------------------|
    |  pyarrow.Table   |
    |  foo: int64      |
    |  bar: int64      |
    |  ----            |
    |  foo: [[1]]      |
    |  bar: [[0]]      |
    └──────────────────┘
)rk   r|   r   r   
null_countr   )rs   plxr'  s      rt   r  DataFrame.null_count&  sN    . ##::<&&--cggi.B.B.DE##F++rw   c                4    U R                   R                  XS9$ )a  Return the DataFrame as a scalar, or return the element at the given row/column.

Arguments:
    row: The *n*-th row.
    column: The column selected via an integer or a string (column name).

Notes:
    If row/col not provided, this is equivalent to df[0,0], with a check that the shape is (1,1).
    With row/col, this is equivalent to df[row,col].

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"foo": [1, None], "bar": [2, 3]})
    >>> nw.from_native(df_native).item(0, 1)
    2
)r   column)rk   r  )rs   r   r  s      rt   r  DataFrame.itemA  s    $ $$))c)AArw   c                T    U R                  U R                  R                  5       5      $ )z Create a copy of this DataFrame.)r   rk   clonerr   s    rt   r  DataFrame.cloneU  s"    ##D$9$9$?$?$ABBrw   c                   > [         TU ]  XS9$ )uR  Take every nth row in the DataFrame and return as a new DataFrame.

Arguments:
    n: Gather every *n*-th row.
    offset: Starting index.

Examples:
    >>> import pyarrow as pa
    >>> import narwhals as nw
    >>> df_native = pa.table({"foo": [1, None, 2, 3]})
    >>> nw.from_native(df_native).gather_every(2)
    ┌──────────────────┐
    |Narwhals DataFrame|
    |------------------|
    |  pyarrow.Table   |
    |  foo: int64      |
    |  ----            |
    |  foo: [[1,2]]    |
    └──────────────────┘
r*  )r  r,  )rs   r   r+  r   s      rt   r,  DataFrame.gather_everyY  s    * w#a#77rw   _)r;  valuesaggregate_functionrI  sort_columns	separatorc               H   Uc  Uc  Sn[        U5      eUb  Sn[        U[        5        [        U[        5      (       a  U/OUn[        U[        5      (       a  U/OUn[        U[        5      (       a  U/OUnU R                  U R                  R                  UUUUUUS95      $ )u  Create a spreadsheet-style pivot table as a DataFrame.

Arguments:
    on: Name of the column(s) whose values will be used as the header of the
        output DataFrame.
    index: One or multiple keys to group by. If None, all remaining columns not
        specified on `on` and `values` will be used. At least one of `index` and
        `values` must be specified.
    values: One or multiple keys to group by. If None, all remaining columns not
        specified on `on` and `index` will be used. At least one of `index` and
        `values` must be specified.
    aggregate_function: Choose from

        - None: no aggregation takes place, will raise error if multiple values
            are in group.
        - A predefined aggregate function string, one of
            {'min', 'max', 'first', 'last', 'sum', 'mean', 'median', 'len'}
    maintain_order: Has no effect and is kept around only for backwards-compatibility.
    sort_columns: Sort the transposed columns by name. Default is by order of
        discovery.
    separator: Used as separator/delimiter in generated column names in case of
        multiple `values` columns.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> data = {
    ...     "ix": [1, 1, 2, 2, 1, 2],
    ...     "col": ["a", "a", "a", "a", "b", "b"],
    ...     "foo": [0, 1, 2, 2, 7, 1],
    ...     "bar": [0, 2, 0, 0, 9, 4],
    ... }
    >>> df_native = pd.DataFrame(data)
    >>> nw.from_native(df_native).pivot(
    ...     "col", index="ix", aggregate_function="sum"
    ... )
    ┌─────────────────────────────────┐
    |       Narwhals DataFrame        |
    |---------------------------------|
    |   ix  foo_a  foo_b  bar_a  bar_b|
    |0   1      1      7      2      9|
    |1   2      4      1      0      4|
    └─────────────────────────────────┘
z3At least one of `values` and `index` must be passedzx`maintain_order` has no effect and is only kept around for backwards-compatibility. You can safely remove this argument.)r$  r;  r  r  r  r  )r!  r   UserWarningr   r   r   rk   pivot)	rs   r$  r;  r  r  rI  r  r  r   s	            rt   r  DataFrame.pivotp  s    n >emGCS/!%7  #{+C((bTb'44&&%eS11u##!!''#5)# ( 	
 		
rw   c                6    U R                   R                  5       $ )a-  Convert to arrow table.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"foo": [1, None], "bar": [2, 3]})
    >>> nw.from_native(df_native).to_arrow()
    pyarrow.Table
    foo: double
    bar: int64
    ----
    foo: [[1,null]]
    bar: [[2,3]]
)rk   r  rr   s    rt   r  DataFrame.to_arrow  s     $$--//rw   )fractionwith_replacementseedc               |    [        X[        U 5      US9nU R                  U R                  R	                  XSUS95      $ )u  Sample from this DataFrame.

Arguments:
    n: Number of items to return. Cannot be used with fraction.
    fraction: Fraction of items to return. Cannot be used with n.
    with_replacement: Allow values to be sampled more than once.
    seed: Seed for the random number generator. If set to None (default), a random
        seed is generated for each sample operation.

Notes:
    The results may not be consistent across libraries.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"foo": [1, 2, 3], "bar": [19, 32, 4]})
    >>> nw.from_native(df_native).sample(n=2)  # doctest:+SKIP
    ┌──────────────────┐
    |Narwhals DataFrame|
    |------------------|
    |      foo  bar    |
    |   2    3    4    |
    |   1    2   32    |
    └──────────────────┘
)r   r  heightr  )r   r  r  )r   r#  r   rk   sample)rs   r   r  r  r  sizes         rt   r  DataFrame.sample  sN    B $3t9GW
 ##!!(( ) 
 	
rw   variabler  r;  r<  r=  c                   > [         TU ]  XX4S9$ )u  Unpivot a DataFrame from wide to long format.

Optionally leaves identifiers set.

This function is useful to massage a DataFrame into a format where one or more
columns are identifier variables (index) while all other columns, considered
measured variables (on), are "unpivoted" to the row axis leaving just
two non-identifier columns, 'variable' and 'value'.

Arguments:
    on: Column(s) to use as values variables; if `on` is empty all columns that
        are not in `index` will be used.
    index: Column(s) to use as identifier variables.
    variable_name: Name to give to the `variable` column. Defaults to "variable".
    value_name: Name to give to the `value` column. Defaults to "value".

Notes:
    If you're coming from pandas, this is similar to `pandas.DataFrame.melt`,
    but with `index` replacing `id_vars` and `on` replacing `value_vars`.
    In other frameworks, you might know this operation as `pivot_longer`.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> data = {"a": ["x", "y", "z"], "b": [1, 3, 5], "c": [2, 4, 6]}
    >>> df_native = pd.DataFrame(data)
    >>> nw.from_native(df_native).unpivot(["b", "c"], index="a")
    ┌────────────────────┐
    | Narwhals DataFrame |
    |--------------------|
    |   a variable  value|
    |0  x        b      1|
    |1  y        b      3|
    |2  z        b      5|
    |3  x        c      2|
    |4  y        c      4|
    |5  z        c      6|
    └────────────────────┘
r:  r  r>  rs   r$  r;  r<  r=  r   s        rt   r>  DataFrame.unpivot  s!    ^ wm  
 	
rw   c                &   > [         TU ]  " U/UQ76 $ )u  Explode the dataframe to long format by exploding the given columns.

Notes:
    It is possible to explode multiple columns only if these columns must have
    matching element counts.

Arguments:
    columns: Column names. The underlying columns being exploded must be of the `List` data type.
    *more_columns: Additional names of columns to explode, specified as positional arguments.

Examples:
    >>> import polars as pl
    >>> import narwhals as nw
    >>> data = {"a": ["x", "y"], "b": [[1, 2], [3]]}
    >>> df_native = pl.DataFrame(data)
    >>> nw.from_native(df_native).explode("b").to_native()
    shape: (3, 2)
    ┌─────┬─────┐
    │ a   ┆ b   │
    │ --- ┆ --- │
    │ str ┆ i64 │
    ╞═════╪═════╡
    │ x   ┆ 1   │
    │ x   ┆ 2   │
    │ y   ┆ 3   │
    └─────┴─────┘
r  rJ  rs   r   rK  r   s      rt   rJ  DataFrame.explode-	  s    8 ww666rw   rk   rm   )rN  z.CompliantDataFrame[Any, Any, DataFrameT, Self])rN  ztype[Series[Any]])rN  ztype[LazyFrame[Any]]rP  r   r   r   rl   rN  rQ  )r  rI   r   &IntoBackend[EagerAllowed | PluginName]rN  DataFrame[Any]rp   )r  zMapping[str, Any]r   2IntoSchema | Mapping[str, IntoDType | None] | Noner   z-IntoBackend[EagerAllowed | PluginName] | NonerN  r  )r  zSequence[Mapping[str, Any]]r   r  r   r  rN  r  )r  r`   r   z!IntoSchema | Sequence[str] | Noner   r  rN  r  )rN  rZ  )NN)r  r   r  bool | NonerN  r`   rN  r   )r  zobject | NonerN  re  )r   zIntoBackend[LazyAllowed] | Noner  z
Any | NonerN  zLazyFrame[Any])rN  rf   )rN  zpd.DataFrame)rN  zpl.DataFrame)r  rQ  rN  r   r  zstr | Path | BytesIOrN  rQ  )r  zstr | Path | BytesIO | NonerN  rc  )rN  r`   )rN  ztuple[int, int])r   r   rN  Series[Any])b)r  r^   rN  zint | float)r  z-tuple[SingleIndexSelector, SingleColSelector]rN  r   )r  z2str | tuple[MultiIndexSelector, SingleColSelector]rN  r  )r  zSingleIndexSelector | MultiIndexSelector | MultiColSelector | tuple[SingleIndexSelector, MultiColSelector] | tuple[MultiIndexSelector, MultiColSelector]rN  rD   )r  a  SingleIndexSelector | SingleColSelector | MultiColSelector | MultiIndexSelector | tuple[SingleIndexSelector, SingleColSelector] | tuple[SingleIndexSelector, MultiColSelector] | tuple[MultiIndexSelector, SingleColSelector] | tuple[MultiIndexSelector, MultiColSelector]rN  zSeries[Any] | Self | Any)r  r   rN  r[  )r  Literal[True]rN  zdict[str, Series[Any]])r  Literal[False]rN  zdict[str, list[Any]])r  r[  rN  z-dict[str, Series[Any]] | dict[str, list[Any]])r;  rZ  rN  ztuple[Any, ...]rS  rT  r;  )r   r   r  str | Sequence[str] | NonerN  rD   rR  rV  )r  r  rN  zlist[tuple[Any, ...]])r  r  rN  zlist[dict[str, Any]])r  r[  rN  z,list[tuple[Any, ...]] | list[dict[str, Any]])rN  zIterator[Series[Any]])r  r  r*  rZ  rN  zIterator[tuple[Any, ...]])r  r  r*  rZ  rN  zIterator[dict[str, Any]])r  r[  r*  rZ  rN  z4Iterator[tuple[Any, ...]] | Iterator[dict[str, Any]]rW  rX     rY  r   r^  r   r[  rN  rD   )
r   rU  rH  r_   rI  r[  r  r  rN  rD   )r   z*IntoExpr | Iterable[IntoExpr] | list[bool]r   r   rN  rD   )r_  rO  r\  r  rN  GroupBy[Self])r_  r^  r\  r  rN  r  )r_  rO  r\  r[  rN  r  r]  r`  Nr  r   rD   r$  rU  r  rX   r  rU  r  rU  r  r   rN  rD   r   rD   r  rc  r  rc  r$  rc  r2  rU  r3  rU  r  rU  r4  rQ   r  r   rN  rD   )rN  r  )rN  r[  rN  rD   )r   
int | Noner  zint | str | NonerN  r   ra  rb  )r$  zstr | list[str]r;  rU  r  rU  r  zPivotAgg | NonerI  r  r  r[  r  r   rN  rD   )rN  zpa.Table)
r   r  r  zfloat | Noner  r[  r  r  rN  rD   rd  rf  )Krh  ri  rj  rk  __doc__r   MAINrr  rl  rm  ru   rx  r|  r   r  classmethodr  r  r  r  r  r  r  r  r  r8   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   rP  r   r`  r  r  r"  r6  r  r  r  r  r  r  r,  r  r  r  r>  rJ  rn  __classcell__r   s   @rt   rp  rp    s   0 #*,,H.% %    & 5$5 8	5
 
5 5n  FJ<
 BF<< C<
 ?< 
< <|  FJK)K CK
 8K 
K KZ  59GG 2G
 8G 
G GR/APN2 48Q #	Q0Q 	Q
 
Qf3(1$1* 6 6@ @5,2 ? + +W2?* Z ZF	  	:	 
	 	p>:p> 
"p>d# 47W WP P#'< <	6< < $(B B	6B400747 7 	7
 
781 16 "
MQ

0J
	
8 
 

(  & .3R RH HW W  %77	57&:> ),(&(;>(	"( ( :='%'47'	!' ' 14CC+.C	=C C
  %UU36U	=U8 ;3 ;DL ;	 ;D535DL5	5>'( " * BF > >. *.+
 $)$/3+
&+
 !	+

 +
 -+
 
+
Z8AE8AVY8A	8At UX2DR	  (:G	 
 LQRL2RLDHRL	RLp -2 $X$X $X *	$X
 $X 
$X $XN TY 8 80 8;P 8	 8  8J &*#	,
 +/+/,
,
 #,
 	,
 (,
 ),
 ,
 
,
 ,
d ##*.+/%)%/Q
Q
 	Q

 Q
 Q
 (Q
 )Q
 #Q
 #Q
 Q
 
Q
 Q
h!&
R&,6B(C8 86 )-)-.2&*"M
M
 &	M

 'M
 ,M
 $M
 M
 M
 
M
^0& (
 "&!&(
(
 	(

 (
 (
 
(
X &*1
 )-'!1
"1
 &	1

 1
 1
 
1
 1
f7 7rw   rp  c            	        ^  \ rS rSr% Sr\R                  rS\S'   \	S7S j5       r
\	S8S j5       rS9S jrS:S jrS;S	 jrS<S
 jr S=     S>S jjrS?S jr        S@U 4S jjrS=SAU 4S jjjr SB     SCS jjr\	SDU 4S jj5       rSDU 4S jjr\	SEU 4S jj5       r      SFU 4S jjr      SFU 4S jjrSGU 4S jjrSHSIU 4S jjjrSS.SJU 4S jjjr S=SSS.       SKS jjjr      SLU 4S jjrSMS jr\ S S!.     SNS" jj5       r!\       SOS# j5       r!S$S!.     SPS% jjr!S$S$S&.         SQU 4S' jjjr"S$S(.       SRU 4S) jjjr#  SSSSS*S+.             STU 4S, jjjjr$SSSSSSS-S*S..                   SUU 4S/ jjjr%SVS0 jr& S=SS1S2S3.         SWU 4S4 jjjjr'SXU 4S5 jjr(S6r)U =r*$ )Yr{  iL	  ap  Narwhals LazyFrame, backed by a native lazyframe.

Warning:
    This class is not meant to be instantiated directly - instead use
    [`narwhals.from_native`][] with a native
    object that is a lazy dataframe from one of the supported
    backend (e.g. polars.LazyFrame, dask_expr._collection.DataFrame):
    ```py
    narwhals.from_native(native_lazyframe)
    ```
rq  rr  c                    U R                   $ rp   rt  rr   s    rt   ru   LazyFrame._compliant[	  rv  rw   c                    [         $ rp   )rp  rr   s    rt   r  LazyFrame._dataframe_	  r~  rw   c                z    UR                   S:  a  Sn[        U5      eUR                  (       a  Sn[        U5      eg )Nr   aM  Order-dependent expressions are not supported for use in LazyFrame.

Hint: To make the expression valid, specify `order_by`.

For example, if you have columns `'price'` and `'date'`:
 - Instead of `nw.col('price').cum_sum()` write `nw.col('price').cum_sum().over(order_by='date')`.
 - Instead of `nw.col('price').diff()` write `nw.col('price').diff().over(order_by='date')`.
 - Instead of `nw.col('price').first()` write `nw.col('price').first().over(order_by='date')`
   or `nw.col('price').first(order_by='date')`.

See https://narwhals-dev.github.io/narwhals/concepts/order_dependence/.a1  Length-changing expressions are not supported for use in LazyFrame, unless
followed by an aggregation.

Hints:
- Instead of `lf.select(nw.col('a').head())`, use `lf.select('a').head()
- Instead of `lf.select(nw.col('a').drop_nulls()).select(nw.sum('a'))`,
  use `lf.select(nw.col('a').drop_nulls().sum())
)n_orderable_opsr0   is_filtration)rs   r   r   s      rt   r   LazyFrame._validate_metadatac	  sN    ##a'Z  (,,!!E  (,, "rw   c                   X l         U   [        U5      (       a  UR                  5       U l        g S[	        U5       3n[        U5      e)NzVExpected Polars LazyFrame or an object that implements `__narwhals_lazyframe__`, got: )rm   r!   __narwhals_lazyframe__rk   r   r  r  s       rt   r  LazyFrame.__init__{	  sE    !"%%$&$=$=$?D!jkoprksjtuC %%rw   c                R    [        SU R                  5       R                  5       5      $ )NzNarwhals LazyFramer  rr   s    rt   r  LazyFrame.__repr__	  r  rw   c                    Sn[        U5      e)Nz%Slicing is not supported on LazyFrame)r   )rs   r  r   s      rt   r  LazyFrame.__getitem__	  s    5nrw   Nc                   U R                   R                  nUc  U R                  U" S0 UD6SS9$ [        R                  " U5      n[        U5      (       a  U R                  U" U40 UD6SS9$ S[        [        5       SU S3n[        U5      e)u2	  Materialize this LazyFrame into a DataFrame.

As each underlying lazyframe has different arguments to set when materializing
the lazyframe into a dataframe, we allow to pass them as kwargs (see examples
below for how to generalize the specification).

Arguments:
    backend: specifies which eager backend collect to. This will be the underlying
        backend for the resulting Narwhals DataFrame. If None, then the following
        default conversions will be applied

        - `polars.LazyFrame` -> `polars.DataFrame`
        - `dask.DataFrame` -> `pandas.DataFrame`
        - `duckdb.PyRelation` -> `pyarrow.Table`
        - `pyspark.DataFrame` -> `pyarrow.Table`

        `backend` can be specified in various ways

        - As `Implementation.<BACKEND>` with `BACKEND` being `PANDAS`, `PYARROW`
            or `POLARS`.
        - As a string: `"pandas"`, `"pyarrow"` or `"polars"`
        - Directly as a module `pandas`, `pyarrow` or `polars`.
    kwargs: backend specific kwargs to pass along. To know more please check the
        backend specific documentation

        - [polars.LazyFrame.collect](https://docs.pola.rs/api/python/dev/reference/lazyframe/api/polars.LazyFrame.collect.html)
        - [dask.dataframe.DataFrame.compute](https://docs.dask.org/en/stable/generated/dask.dataframe.DataFrame.compute.html)

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> lf_native = duckdb.sql("SELECT * FROM VALUES (1, 2), (3, 4) df(a, b)")
    >>> lf = nw.from_native(lf_native)
    >>> lf
    ┌──────────────────┐
    |Narwhals LazyFrame|
    |------------------|
    |┌───────┬───────┐ |
    |│   a   │   b   │ |
    |│ int32 │ int32 │ |
    |├───────┼───────┤ |
    |│     1 │     2 │ |
    |│     3 │     4 │ |
    |└───────┴───────┘ |
    └──────────────────┘
    >>> lf.collect()
    ┌──────────────────┐
    |Narwhals DataFrame|
    |------------------|
    |  pyarrow.Table   |
    |  a: int32        |
    |  b: int32        |
    |  ----            |
    |  a: [[1,3]]      |
    |  b: [[2,4]]      |
    └──────────────────┘
r  r   z-Unsupported `backend` value.
Expected one of z or None, got: r  rp   )	rk   collectr  r   r  r   r   r   r!  )rs   r   r   r  eager_backendr   s         rt   r  LazyFrame.collect	  s    x ''//???7#:6#:&?II&33G< //??7=#CF#C6?RR>xH]?^>__no|n}}~orw   c                    [        U SS9$ )u  Convert Narwhals LazyFrame to native one.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> lf_native = duckdb.sql("SELECT * FROM VALUES (1, 2), (3, 4) df(a, b)")
    >>> nw.from_native(lf_native).to_native()
    ┌───────┬───────┐
    │   a   │   b   │
    │ int32 │ int32 │
    ├───────┼───────┤
    │     1 │     2 │
    │     3 │     4 │
    └───────┴───────┘
    <BLANKLINE>
F)narwhals_objectpass_throughr7   rr   s    rt   r8   LazyFrame.to_native	  s    " EBBrw   c                ,   > [         TU ]  " U/UQ70 UD6$ )u:  Pipe function call.

Arguments:
    function: Function to apply.
    args: Positional arguments to pass to function.
    kwargs: Keyword arguments to pass to function.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> lf_native = duckdb.sql("SELECT * FROM VALUES (1, 2), (3, 4) df(a, b)")
    >>> nw.from_native(lf_native).pipe(lambda x: x.select("a")).to_native()
    ┌───────┐
    │   a   │
    │ int32 │
    ├───────┤
    │     1 │
    │     3 │
    └───────┘
    <BLANKLINE>
r  r  s       rt   r   LazyFrame.pipe	  s    6 w|H6t6v66rw   c                   > [         TU ]  US9$ )u  Drop rows that contain null values.

Arguments:
    subset: Column name(s) for which null values are considered. If set to None
        (default), use all columns.

Notes:
    pandas handles null values differently from Polars and PyArrow.
    See [null_handling](../concepts/null_handling.md) for reference.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> lf_native = duckdb.sql("SELECT * FROM VALUES (1, NULL), (3, 4) df(a, b)")
    >>> nw.from_native(lf_native).drop_nulls()
    ┌──────────────────┐
    |Narwhals LazyFrame|
    |------------------|
    |┌───────┬───────┐ |
    |│   a   │   b   │ |
    |│ int32 │ int32 │ |
    |├───────┼───────┤ |
    |│     3 │     4 │ |
    |└───────┴───────┘ |
    └──────────────────┘
r   r  r	  s     rt   r   LazyFrame.drop_nulls
  s    6 w!!00rw   c                   [        U[        5      (       a  U/OUnU R                  U R                  R	                  XS95      $ )u  Insert column which enumerates rows.

Arguments:
    name: The name of the column as a string. The default is "index".
    order_by: Column(s) to order by when computing the row index. Nulls are placed first.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> lf_native = duckdb.sql("SELECT * FROM VALUES (1, 5), (2, 4) df(a, b)")
    >>> nw.from_native(lf_native).with_row_index(order_by="a").sort("a").collect()
    ┌──────────────────┐
    |Narwhals DataFrame|
    |------------------|
    |  pyarrow.Table   |
    |  index: int64    |
    |  a: int32        |
    |  b: int32        |
    |  ----            |
    |  index: [[0,1]]  |
    |  a: [[1,2]]      |
    |  b: [[5,4]]      |
    └──────────────────┘
    >>> nw.from_native(lf_native).with_row_index(order_by="b").sort("a").collect()
    ┌──────────────────┐
    |Narwhals DataFrame|
    |------------------|
    |  pyarrow.Table   |
    |  index: int64    |
    |  a: int32        |
    |  b: int32        |
    |  ----            |
    |  index: [[1,0]]  |
    |  a: [[1,2]]      |
    |  b: [[5,4]]      |
    └──────────────────┘
r  r  r  s       rt   r  LazyFrame.with_row_index
  sD    P #-Xs";";XJ	##!!000J
 	
rw   c                   > U R                   R                  [        R                  La  Sn[	        U[
        5        [        TU ]  $ )aC  Get an ordered mapping of column names to their data type.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> lf_native = duckdb.sql("SELECT * FROM VALUES (1, 4.5), (3, 2.) df(a, b)")
    >>> nw.from_native(lf_native).schema  # doctest:+SKIP
    Schema({'a': Int32, 'b': Decimal(precision=2, scale=1)})
zResolving the schema of a LazyFrame is a potentially expensive operation. Use `LazyFrame.collect_schema()` to get the schema without this warning.)rk   rr  r   V1r   r1   r  r   )rs   r   r   s     rt   r   LazyFrame.schemaK
  s?       ));[  #12w~rw   c                    > [         TU ]  5       $ )a<  Get an ordered mapping of column names to their data type.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> lf_native = duckdb.sql("SELECT * FROM VALUES (1, 4.5), (3, 2.) df(a, b)")
    >>> nw.from_native(lf_native).collect_schema()
    Schema({'a': Int32, 'b': Decimal(precision=2, scale=1)})
r  r  s    rt   r   LazyFrame.collect_schema^
  r  rw   c                   > [         TU ]  $ )a  Get column names.

Note:
    The pandas-like and dask backends allow non-string column names
    (e.g. integers or booleans). While discouraged, this is supported,
    so the return type is not guaranteed to be `list[str]`.

    See [concepts - column names](../concepts/column_names.md) for details.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> lf_native = duckdb.sql("SELECT * FROM VALUES (1, 4.5), (3, 2.) df(a, b)")
    >>> nw.from_native(lf_native).columns
    ['a', 'b']
r  r  s    rt   r   LazyFrame.columnsj
  r  rw   c                Z   > U(       d  U(       d  Sn[        U5      e[        TU ]  " U0 UD6$ )u  Add columns to this LazyFrame.

Added columns will replace existing columns with the same name.

Arguments:
    *exprs: Column(s) to add, specified as positional arguments.
             Accepts expression input. Strings are parsed as column names, other
             non-expression inputs are parsed as literals.

    **named_exprs: Additional columns to add, specified as keyword arguments.
                    The columns will be renamed to the keyword used.

Note:
    Creating a new LazyFrame using this method does not create a new copy of
    existing data.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> lf_native = duckdb.sql("SELECT * FROM VALUES (1, 4.5), (3, 2.) df(a, b)")
    >>> nw.from_native(lf_native).with_columns(c=nw.col("a") + 1)
    ┌────────────────────────────────┐
    |       Narwhals LazyFrame       |
    |--------------------------------|
    |┌───────┬──────────────┬───────┐|
    |│   a   │      b       │   c   │|
    |│ int32 │ decimal(2,1) │ int32 │|
    |├───────┼──────────────┼───────┤|
    |│     1 │          4.5 │     2 │|
    |│     3 │          2.0 │     4 │|
    |└───────┴──────────────┴───────┘|
    └────────────────────────────────┘
z@At least one expression must be passed to LazyFrame.with_columns)r!  r  r   rs   r   r   r   r   s       rt   r   LazyFrame.with_columns~
  s/    H [TCS/!w#U:k::rw   c                Z   > U(       d  U(       d  Sn[        U5      e[        TU ]  " U0 UD6$ )uY  Select columns from this LazyFrame.

Arguments:
    *exprs: Column(s) to select, specified as positional arguments.
        Accepts expression input. Strings are parsed as column names.
    **named_exprs: Additional columns to select, specified as keyword arguments.
        The columns will be renamed to the keyword used.

Notes:
    If you'd like to select a column whose name isn't a string (for example,
    if you're working with pandas) then you should explicitly use `nw.col` instead
    of just passing the column name. For example, to select a column named
    `0` use `df.select(nw.col(0))`, not `df.select(0)`.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> lf_native = duckdb.sql("SELECT * FROM VALUES (1, 4.5), (3, 2.) df(a, b)")
    >>> nw.from_native(lf_native).select("a", a_plus_1=nw.col("a") + 1)
    ┌────────────────────┐
    | Narwhals LazyFrame |
    |--------------------|
    |┌───────┬──────────┐|
    |│   a   │ a_plus_1 │|
    |│ int32 │  int32   │|
    |├───────┼──────────┤|
    |│     1 │        2 │|
    |│     3 │        4 │|
    |└───────┴──────────┘|
    └────────────────────┘
z:At least one expression must be passed to LazyFrame.select)r!  r  r   r  s       rt   r   LazyFrame.select
  s.    D [NCS/!w~u444rw   c                "   > [         TU ]  U5      $ )u  Rename column names.

Arguments:
    mapping: Key value pairs that map from old name to new name, or a
              function that takes the old name as input and returns the
              new name.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> lf_native = duckdb.sql("SELECT * FROM VALUES (1, 4.5), (3, 2.) df(a, b)")
    >>> nw.from_native(lf_native).rename({"a": "c"})
    ┌────────────────────────┐
    |   Narwhals LazyFrame   |
    |------------------------|
    |┌───────┬──────────────┐|
    |│   c   │      b       │|
    |│ int32 │ decimal(2,1) │|
    |├───────┼──────────────┤|
    |│     1 │          4.5 │|
    |│     3 │          2.0 │|
    |└───────┴──────────────┘|
    └────────────────────────┘
r8  r9  s     rt   r   LazyFrame.rename
  s    2 w~g&&rw   c                "   > [         TU ]  U5      $ )u  Get `n` rows.

Arguments:
    n: Number of rows to return.

Examples:
    >>> import dask.dataframe as dd
    >>> import narwhals as nw
    >>> lf_native = dd.from_dict({"a": [1, 2, 3], "b": [4, 5, 6]}, npartitions=1)
    >>> nw.from_native(lf_native).head(2).collect()
    ┌──────────────────┐
    |Narwhals DataFrame|
    |------------------|
    |        a  b      |
    |     0  1  4      |
    |     1  2  5      |
    └──────────────────┘
r<  r=  s     rt   r   LazyFrame.head
  rA  rw   Tr   c               6   > [         TU ]  " [        U5      SU06$ )u  Remove columns from the LazyFrame.

Arguments:
    *columns: Names of the columns that should be removed from the dataframe.
    strict: Validate that all column names exist in the schema and throw an
        exception if a column name does not exist in the schema.

Warning:
    `strict` argument is ignored for `polars<1.0.0`.

    Please consider upgrading to a newer version or pass to eager mode.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> lf_native = duckdb.sql("SELECT * FROM VALUES (1, 2), (3, 4) df(a, b)")
    >>> nw.from_native(lf_native).drop("a").to_native()
    ┌───────┐
    │   b   │
    │ int32 │
    ├───────┤
    │     2 │
    │     4 │
    └───────┘
    <BLANKLINE>
r   rC  rD  s      rt   r   LazyFrame.drop
  s    6 w|WW-=f==rw   rF  )rH  r  c                   US;  a  SS SU 3n[        U5      eUS;   a  U(       d  Sn[        U5      e[        U[        5      (       a  U/nU R	                  U R
                  R                  XUS95      $ )u  Drop duplicate rows from this LazyFrame.

Arguments:
    subset: Column name(s) to consider when identifying duplicate rows.
             If set to `None`, use all columns.
    keep: {'any', 'none', 'first', 'last}
        Which of the duplicate rows to keep.

        * 'any': Does not give any guarantee of which row is kept.
        * 'none': Don't keep duplicate rows.
        * 'first': Keep the first row. Requires `order_by` to be specified.
        * 'last': Keep the last row. Requires `order_by` to be specified.
    order_by: Column(s) to order by when computing the row index. Nulls are placed first.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> lf_native = duckdb.sql("SELECT * FROM VALUES (1, 3), (1, 4) df(a, b)")
    >>> nw.from_native(lf_native).unique("a").sort("a", descending=True)
    ┌──────────────────┐
    |Narwhals LazyFrame|
    |------------------|
    |┌───────┬───────┐ |
    |│   a   │   b   │ |
    |│ int32 │ int32 │ |
    |├───────┼───────┤ |
    |│     1 │     3 │ |
    |└───────┴───────┘ |
    └──────────────────┘
>   rF  rK  rL  rM  rN  rO  r   >   rK  rM  znarwhals.LazyFrame makes no assumptions about row order, so only 'first' and 'last' are only supported if `order_by` is passed.)r   rH  r  )r!  r0   r   r   r   rk   rP  )rs   r   rH  r  r   s        rt   rP  LazyFrame.unique  s    J 77<=WTFKCS/!$$XQ  (,,fc""XF##!!((H(U
 	
rw   c                   > [        S U 5       5      n[        U5      (       a  Sn[        U5      e[        TU ]  " U0 UD6$ )u_  Filter the rows in the LazyFrame based on a predicate expression.

The original order of the remaining rows is preserved.

Arguments:
    *predicates: Expression(s) that evaluates to a boolean Series.
    **constraints: Column filters; use `name = value` to filter columns by the supplied value.
        Each constraint will behave the same as `nw.col(name).eq(value)`, and will be implicitly
        joined with the other filter conditions using &.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> df_native = duckdb.sql('''
    ...     SELECT * FROM VALUES
    ...         (1, 6, 'a'),
    ...         (2, 7, 'b'),
    ...         (3, 8, 'c')
    ...     df(foo, bar, ham)
    ... ''')

    Filter on one condition

    >>> nw.from_native(df_native).filter(nw.col("foo") > 1).to_native()
    ┌───────┬───────┬─────────┐
    │  foo  │  bar  │   ham   │
    │ int32 │ int32 │ varchar │
    ├───────┼───────┼─────────┤
    │     2 │     7 │ b       │
    │     3 │     8 │ c       │
    └───────┴───────┴─────────┘
    <BLANKLINE>

    Filter on multiple conditions with implicit `&`

    >>> nw.from_native(df_native).filter(
    ...     nw.col("foo") < 3, nw.col("ham") == "a"
    ... ).to_native()
    ┌───────┬───────┬─────────┐
    │  foo  │  bar  │   ham   │
    │ int32 │ int32 │ varchar │
    ├───────┼───────┼─────────┤
    │     1 │     6 │ a       │
    └───────┴───────┴─────────┘
    <BLANKLINE>

    Filter on multiple conditions with `|`

    >>> nw.from_native(df_native).filter(
    ...     (nw.col("foo") == 1) | (nw.col("ham") == "c")
    ... ).to_native()
    ┌───────┬───────┬─────────┐
    │  foo  │  bar  │   ham   │
    │ int32 │ int32 │ varchar │
    ├───────┼───────┼─────────┤
    │     1 │     6 │ a       │
    │     3 │     8 │ c       │
    └───────┴───────┴─────────┘
    <BLANKLINE>

    Filter using `**kwargs` syntax

    >>> nw.from_native(df_native).filter(foo=2, ham="b").to_native()
    ┌───────┬───────┬─────────┐
    │  foo  │  bar  │   ham   │
    │ int32 │ int32 │ varchar │
    ├───────┼───────┼─────────┤
    │     2 │     7 │ b       │
    └───────┴───────┴─────────┘
    <BLANKLINE>
c              3  \   #    U  H"  n[        U5      (       a  [        U5      OUv   M$     g 7frp   )r$   r   )r   rV  s     rt   r   #LazyFrame.filter.<locals>.<genexpr>  s!     Rz!AE!HA=zs   *,zX`LazyFrame.filter` is not supported with Python boolean masks - use expressions instead.)r   r*   r   r  r   )rs   r   r   predicates_r   r   s        rt   r   LazyFrame.filterO  sD    T RzRR+K88lCC. w~{:k::rw   c                :    U R                   R                  U5        g)a  Write LazyFrame to Parquet file.

This may allow larger-than-RAM datasets to be written to disk.

Arguments:
    file: String, path object or file-like object to which the dataframe will be
        written.

Examples:
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.LazyFrame({"foo": [1, 2], "bar": [6.0, 7.0]})
    >>> df = nw.from_native(df_native)
    >>> df.sink_parquet("out.parquet")  # doctest:+SKIP
N)rk   sink_parquetr  s     rt   r  LazyFrame.sink_parquet  s      	**40rw   .r[  c                   g rp   rq   r^  s      rt   r`  LazyFrame.group_by        rw   c                   g rp   rq   r^  s      rt   r`  r    r  rw   Fc                 ^ SSK Jn  [        U5      n[        S U 5       5      (       a  U" XUS9$ SSKJn  SSKJm  [        U4S jU 5       5      nU(       a  [        U5      (       a  Sn[        U5      e[        XFS	S
9 VV	s/ s H  u  pU	(       a  UOU" U5      PM     n
nn	U R                  " U
6 n[        USS06  U" XUS9$ s  sn	nf )u  Start a group by operation.

Arguments:
    *keys: Column(s) to group by. Accepts expression input. Strings are parsed as
        column names.
    drop_null_keys: if True, then groups where any key is null won't be
        included in the result.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> df_native = duckdb.sql(
    ...     "SELECT * FROM VALUES (1, 'a'), (2, 'b'), (3, 'a') df(a, b)"
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.group_by("b").agg(nw.col("a").sum()).sort("b").to_native()
    ┌─────────┬────────┐
    │    b    │   a    │
    │ varchar │ int128 │
    ├─────────┼────────┤
    │ a       │      4 │
    │ b       │      2 │
    └─────────┴────────┘
    <BLANKLINE>

    Expressions are also accepted.

    >>> df.group_by(nw.col("b").str.len_chars()).agg(
    ...     nw.col("a").sum()
    ... ).to_native()
    ┌───────┬────────┐
    │   b   │   a    │
    │ int64 │ int128 │
    ├───────┼────────┤
    │     1 │      6 │
    └───────┴────────┘
    <BLANKLINE>
r   )rP   c              3  B   #    U  H  n[        U[        5      v   M     g 7frp   r   rf  s     rt   r   %LazyFrame.group_by.<locals>.<genexpr>  rh  r   r[  ri  rj  c              3  <   >#    U  H  n[        UT5      v   M     g 7frp   rm  )r   r  rk  s     rt   r   r    s     CAJq$//s   z5drop_null_keys cannot be True when keys contains ExprTr   r   zLazyFrame.group_by)rn  rP   r   r   ro  r   rp  rk  r   rF  r   rq  r   r   )rs   r\  r_  rP   rr  r   key_is_exprr   r  rt  ru  rv  rk  s               @rt   r`  r    s    R 	2DM	9y999t~NN &CCCc+..IC%c** ")F
F
 Ac!f$F 	 
 22E:)	
+?	
 4OO
s   Cr  c               ,   > [         TU ]  " U/UQ7X#S.6$ )u  Sort the LazyFrame by the given columns.

Arguments:
    by: Column(s) names to sort by.
    *more_by: Additional columns to sort by, specified as positional arguments.
    descending: Sort in descending order. When sorting by multiple columns, can be
        specified per column by passing a sequence of booleans.
    nulls_last: Place null values last; can specify a single boolean applying to
        all columns or a sequence of booleans for per-column control.

Warning:
    Unlike Polars, it is not possible to specify a sequence of booleans for
    `nulls_last` in order to control per-column behaviour. Instead a single
    boolean is applied for all `by` columns.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> df_native = duckdb.sql(
    ...     "SELECT * FROM VALUES (1, 6.0, 'a'), (2, 5.0, 'c'), (NULL, 4.0, 'b') df(a, b, c)"
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.sort("a")
    ┌──────────────────────────────────┐
    |        Narwhals LazyFrame        |
    |----------------------------------|
    |┌───────┬──────────────┬─────────┐|
    |│   a   │      b       │    c    │|
    |│ int32 │ decimal(2,1) │ varchar │|
    |├───────┼──────────────┼─────────┤|
    |│  NULL │          4.0 │ b       │|
    |│     1 │          6.0 │ a       │|
    |│     2 │          5.0 │ c       │|
    |└───────┴──────────────┴─────────┘|
    └──────────────────────────────────┘
r  rx  ry  s        rt   r  LazyFrame.sort  s    V w|BWWZWWrw   r
  c                   > [         TU ]  XUS9$ )u  Return the `k` largest rows.

Non-null elements are always preferred over null elements,
regardless of the value of reverse. The output is not guaranteed
to be in any particular order, sort the outputs afterwards if you wish the output to be sorted.

Arguments:
    k: Number of rows to return.
    by: Column(s) used to determine the top rows. Accepts expression input. Strings are parsed as column names.
    reverse: Consider the k smallest elements of the by column(s) (instead of the k largest).
        This can be specified per column by passing a sequence of booleans.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> df_native = duckdb.sql(
    ...     "SELECT * FROM VALUES ('a', 2), ('b', 1), ('a', 1), ('b', 3), (NULL, 2), ('c', 1) df(a, b)"
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.top_k(4, by=["b", "a"])
    ┌───────────────────┐
    |Narwhals LazyFrame |
    |-------------------|
    |┌─────────┬───────┐|
    |│    a    │   b   │|
    |│ varchar │ int32 │|
    |├─────────┼───────┤|
    |│ b       │     3 │|
    |│ a       │     2 │|
    |│ NULL    │     2 │|
    |│ c       │     1 │|
    |└─────────┴───────┘|
    └───────────────────┘
r  r|  r}  s       rt   r  LazyFrame.top_k,  s    J w}Qw}77rw   r  r  c          	     "   > [         TU ]  XXEX&S9$ )u  Add a join operation to the Logical Plan.

Arguments:
    other: Lazy DataFrame to join with.
    on: Name(s) of the join columns in both DataFrames. If set, `left_on` and
        `right_on` should be None.
    how: Join strategy.

          * *inner*: Returns rows that have matching values in both tables.
          * *left*: Returns all rows from the left table, and the matched rows from the right table.
          * *full*: Returns all rows in both dataframes, with the suffix appended to the right join keys.
          * *cross*: Returns the Cartesian product of rows from both tables.
          * *semi*: Filter rows that have a match in the right table.
          * *anti*: Filter rows that do not have a match in the right table.
    left_on: Join column of the left DataFrame.
    right_on: Join column of the right DataFrame.
    suffix: Suffix to append to columns with a duplicate name.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> df_native1 = duckdb.sql(
    ...     "SELECT * FROM VALUES (1, 'a'), (2, 'b') df(a, b)"
    ... )
    >>> df_native2 = duckdb.sql(
    ...     "SELECT * FROM VALUES (1, 'x'), (3, 'y') df(a, c)"
    ... )
    >>> df1 = nw.from_native(df_native1)
    >>> df2 = nw.from_native(df_native2)
    >>> df1.join(df2, on="a")
    ┌─────────────────────────────┐
    |     Narwhals LazyFrame      |
    |-----------------------------|
    |┌───────┬─────────┬─────────┐|
    |│   a   │    b    │    c    │|
    |│ int32 │ varchar │ varchar │|
    |├───────┼─────────┼─────────┤|
    |│     1 │ a       │ x       │|
    |└───────┴─────────┴─────────┘|
    └─────────────────────────────┘
r  r  r  s          rt   r"  LazyFrame.joinS  s#    f w|G2  
 	
rw   r/  r  c               .   > [         T
U ]  UUUUUUUUU	S9	$ )u
  Perform an asof join.

This is similar to a left-join except that we match on nearest key rather than equal keys.

For Polars, both DataFrames must be sorted by the `on` key (within each `by` group
if specified).

Arguments:
    other: DataFrame to join with.
    left_on: Name(s) of the left join column(s).
    right_on: Name(s) of the right join column(s).
    on: Join column of both DataFrames. If set, left_on and right_on should be None.
    by_left: join on these columns before doing asof join
    by_right: join on these columns before doing asof join
    by: join on these columns before doing asof join
    strategy: Join strategy. The default is "backward".

          * *backward*: selects the last row in the right DataFrame whose "on" key is less than or equal to the left's key.
          * *forward*: selects the first row in the right DataFrame whose "on" key is greater than or equal to the left's key.
          * *nearest*: search selects the last row in the right DataFrame whose value is nearest to the left's key.

    suffix: Suffix to append to columns with a duplicate name.

Examples:
    >>> from datetime import datetime
    >>> import polars as pl
    >>> import narwhals as nw
    >>> data_gdp = {
    ...     "datetime": [
    ...         datetime(2016, 1, 1),
    ...         datetime(2017, 1, 1),
    ...         datetime(2018, 1, 1),
    ...         datetime(2019, 1, 1),
    ...         datetime(2020, 1, 1),
    ...     ],
    ...     "gdp": [4164, 4411, 4566, 4696, 4827],
    ... }
    >>> data_population = {
    ...     "datetime": [
    ...         datetime(2016, 3, 1),
    ...         datetime(2018, 8, 1),
    ...         datetime(2019, 1, 1),
    ...     ],
    ...     "population": [82.19, 82.66, 83.12],
    ... }
    >>> gdp_native = pl.DataFrame(data_gdp)
    >>> population_native = pl.DataFrame(data_population)
    >>> gdp = nw.from_native(gdp_native)
    >>> population = nw.from_native(population_native)
    >>> population.join_asof(gdp, on="datetime", strategy="backward").to_native()
    shape: (3, 3)
    ┌─────────────────────┬────────────┬──────┐
    │ datetime            ┆ population ┆ gdp  │
    │ ---                 ┆ ---        ┆ ---  │
    │ datetime[μs]        ┆ f64        ┆ i64  │
    ╞═════════════════════╪════════════╪══════╡
    │ 2016-03-01 00:00:00 ┆ 82.19      ┆ 4164 │
    │ 2018-08-01 00:00:00 ┆ 82.66      ┆ 4566 │
    │ 2019-01-01 00:00:00 ┆ 83.12      ┆ 4696 │
    └─────────────────────┴────────────┴──────┘
r  r  r  s             rt   r6  LazyFrame.join_asof  s8    T w  ! 

 
	
rw   c                    U $ )z}Restrict available API methods to lazy-only ones.

This is a no-op, and exists only for compatibility with `DataFrame.lazy`.
rq   rr   s    rt   r  LazyFrame.lazy  s	    
 rw   r  r  r  c                   > [         TU ]  XX4S9$ )ua  Unpivot a DataFrame from wide to long format.

Optionally leaves identifiers set.

This function is useful to massage a DataFrame into a format where one or more
columns are identifier variables (index) while all other columns, considered
measured variables (on), are "unpivoted" to the row axis leaving just
two non-identifier columns, 'variable' and 'value'.

Arguments:
    on: Column(s) to use as values variables; if `on` is empty all columns that
        are not in `index` will be used.
    index: Column(s) to use as identifier variables.
    variable_name: Name to give to the `variable` column. Defaults to "variable".
    value_name: Name to give to the `value` column. Defaults to "value".

Notes:
    If you're coming from pandas, this is similar to `pandas.DataFrame.melt`,
    but with `index` replacing `id_vars` and `on` replacing `value_vars`.
    In other frameworks, you might know this operation as `pivot_longer`.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> df_native = duckdb.sql(
    ...     "SELECT * FROM VALUES ('x', 1, 2), ('y', 3, 4), ('z', 5, 6) df(a, b, c)"
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.unpivot(on=["b", "c"], index="a").sort("a", "variable").to_native()
    ┌─────────┬──────────┬───────┐
    │    a    │ variable │ value │
    │ varchar │ varchar  │ int32 │
    ├─────────┼──────────┼───────┤
    │ x       │ b        │     1 │
    │ x       │ c        │     2 │
    │ y       │ b        │     3 │
    │ y       │ c        │     4 │
    │ z       │ b        │     5 │
    │ z       │ c        │     6 │
    └─────────┴──────────┴───────┘
    <BLANKLINE>
r:  r  r  s        rt   r>  LazyFrame.unpivot  s!    d wm  
 	
rw   c                &   > [         TU ]  " U/UQ76 $ )uF  Explode the dataframe to long format by exploding the given columns.

Notes:
    It is possible to explode multiple columns only if these columns have
    matching element counts.

Arguments:
    columns: Column names. The underlying columns being exploded must be of the `List` data type.
    *more_columns: Additional names of columns to explode, specified as positional arguments.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> df_native = duckdb.sql(
    ...     "SELECT * FROM VALUES ('x', [1, 2]), ('y', [3, 4]), ('z', [5, 6]) df(a, b)"
    ... )
    >>> df = nw.from_native(df_native)
    >>> df.explode("b").to_native()
    ┌─────────┬───────┐
    │    a    │   b   │
    │ varchar │ int32 │
    ├─────────┼───────┤
    │ x       │     1 │
    │ x       │     2 │
    │ y       │     3 │
    │ y       │     4 │
    │ z       │     5 │
    │ z       │     6 │
    └─────────┴───────┘
    <BLANKLINE>
r  r  s      rt   rJ  LazyFrame.explode  s    @ ww666rw   r  )rN  z)CompliantLazyFrame[Any, LazyFrameT, Self])rN  ztype[DataFrame[Any]]rP  r  r  )r  zstr | slicerN  r   rp   )r   z+IntoBackend[Polars | Pandas | Arrow] | Noner   r   rN  r  )rN  re   rS  rT  r  )r   r   r  rg  rN  rD   rR  rV  rW  rX  r  rY  r  )r   rU  rH  r_   r  r  rN  rD   r\  r  )r_  rO  r\  r  rN  LazyGroupBy[Self])r_  r^  r\  r  rN  r*  )r_  rO  r\  r[  rN  r*  r]  r`  r  r  r  r  rd  rf  )+rh  ri  rj  rk  r  r   r  rr  rl  rm  ru   r  r   r  r  r  r  r8   r   r   r  r   r   r   r   r   r   r   r   rP  r   r  r   r`  r  r  r"  r6  r  r>  rJ  rn  r  r  s   @rt   r{  r{  L	  s&   
 #*,,H.% %  -0&P
 FJCBCUXC	CJC(747 7 	7
 
7:1 1< "+
+
0C+
	+
Z  $
(  &';3';DL';	';R%53%5DL%5	%5N'6 * BF > >> *.2
 $)/32
&2
 !	2

 -2
 
2
hO;8O;ILO;	O;b1$ UX 2 DR 	     ( :G 	   
 LQAP2APDHAP	APN -2 +X+X +X *	+X
 +X 
+X +X\ TY%8%80%8;P%8	%8 %8T &*#	5
 +/+/5
5
 #5
 	5
 (5
 )5
 5
 
5
 5
v ##*.+/%)%/T
T
 	T

 T
 T
 (T
 )T
 #T
 #T
 T
 
T
 T
l &*4
 )-'!4
"4
 &	4

 4
 4
 
4
 4
l 7  7rw   r{  )
__future__r   abcr   	functoolsr   	itertoolsr   typingr   r   r	   r
   r   r   r   r   r   narwhals._exceptionsr   narwhals._expression_parsingr   r   r   narwhals._typingr   r   r   r   narwhals._utilsr   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   narwhals.dependenciesr-   r.   narwhals.exceptionsr/   r0   r1   r   r2   r3   narwhals.schemar4   r  r6   narwhals.translater8   collections.abcr9   r:   r;   r<   r=   ior>   pathlibr?   typesr@   rA   rB   pandaspdpolarsplpyarrowpatyping_extensionsrC   rD   narwhals._compliantrE   rF   narwhals._compliant.typingrG   rH   narwhals._translaterI   rJ   rK   rL   rM   rN   rn  rO   rP   narwhals.typingrQ   rR   rS   rT   rU   rV   rW   rX   rY   _MultiColSelectorrZ   _MultiIndexSelectorr[   r\   r]   r^   r_   r`   ra   rb   rl  rc   re   rf   rg   ri   rp  r{  rq   rw   rt   <module>rI     s_   "   
 
 
 / 
 T S     . F 
 F " " (OO -1J;92  7    & 
4BJ	
);
/\9
\9
CL> ) > B I BRW  RWj
B7	*% B7J<q7	*% q7rw   