
    hh                   "   % 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  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  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  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  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   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(  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-  S S$K&J.r.  S S%K&J/r/  S S&K&J0r0  S S'K&J1r1  S S(K&J2r2  S S)K&J3r3  \(       a  S S*K4J5r5  S S+K6J7r7  S S,K8J9r9  S S-K:r;S S-K<r=S S-K>r?S S.K@JArA  S S/K@JBrB  S S0K@JCrC  S S1K@JDrD  S S2KEJFrF  S S3KEJGrG  S S4KEJHrH  S S5KIJJrJ  S S6KKJLrL  S S7KKJMrM  S S8KNJOrO  S S9KPJQrQ  S S:KPJRrR  S S;KPJSrS  S S<KPJTrT  S S=KPJUrU  S S>KPJVrV  S S?KPJWrX  S S@KPJYrZ  S SAKPJ[r[  S SBKPJ\r\  S SCKPJ]r]  S SDKPJ^r^  S SEKPJ_r_  S SFKPJ`r`  \B" SG5      ra\" SHSISJ9rb\" SKSISJ9rc\" SLSMSJ9rd\" SN5      reSOrWSP\fSQ'   SRrYSP\fSS'    " ST SU\
\b   5      rg " SV SW\g\d   5      rh " SX SY\g\c   5      rig-)Z    )annotations)abstractmethod)chain)TYPE_CHECKING)Any)Callable)Generic)Iterable)Iterator)Literal)NoReturn)Sequence)TypeVar)overload)warn)ExprKind)all_exprs_are_scalar_like)!check_expressions_preserve_length)
infer_kind)is_scalar_like)
get_polars)is_numpy_array)ColumnNotFoundError)InvalidIntoExprError)LengthChangingExprError)OrderDependentExprError)Schema	to_native)Implementation)find_stacklevel)flatten)generate_repr)is_compliant_dataframe)is_compliant_lazyframe)is_index_selector)
is_list_of)is_sequence_like)is_slice_none)issue_deprecation_warning)parse_version)supports_arrow_c_stream)BytesIO)Path)
ModuleTypeN)Concatenate)	ParamSpec)Self)	TypeAlias)CompliantDataFrame)CompliantLazyFrame)IntoCompliantExpr)EagerNamespaceAnyGroupByLazyGroupBySeries)AsofJoinStrategy)IntoDataFrame)IntoExpr)	IntoFrame)JoinStrategy)LazyUniqueKeepStrategy)MultiColSelector)MultiIndexSelector)PivotAgg)SingleColSelector)SingleIndexSelector)SizeUnit)UniqueKeepStrategy)_2DArrayPS_FrameTrA   )boundFrameT
DataFrameTr?   Rz_MultiColSelector[Series[Any]]r3   rD   z _MultiIndexSelector[Series[Any]]rE   c            	      .   \ rS rSr% S\S'   S\S'   S(S jrS)S jrS*S jr      S+S	 jr\	S,S
 j5       r
\S-S j5       rS-S jr        S.S jrS/S0S jjrS1S jr\S2S j5       r      S3S jr      S3S jrS4S jrS5S jrS5S jrS6S jr      S7S jrSSS.         S8S jjr  S9SSSS.             S:S jjjrS;S<S jjrSSSSSSS SS!.                   S=S" jjr          S>S# jrS?S$ jrS?S% jrS@S& jr S'r!g)A	BaseFrame[   r   _compliant_frame&Literal['full', 'lazy', 'interchange']_levelc                6    U R                   R                  5       $ N)rU   __native_namespace__selfs    D/var/www/html/env/lib/python3.13/site-packages/narwhals/dataframe.pyrZ   BaseFrame.__native_namespace___   s    $$99;;    c                6    U R                   R                  5       $ rY   )rU   __narwhals_namespace__r[   s    r]   ra    BaseFrame.__narwhals_namespace__b   s    $$;;==r_   c                4    U R                  XR                  S9$ )Nlevel)	__class__rW   )r\   dfs     r]   _with_compliantBaseFrame._with_compliante   s    ~~b~44r_   c                p   / n/ n[        U5       H>  nU R                  U5      nUR                  U5        UR                  [        USS95        M@     UR	                  5        HO  u  puU R                  U5      R                  U5      nUR                  U5        UR                  [        USS95        MQ     X44$ )zjProcess `args` and `kwargs`, extracting underlying objects as we go, interpreting strings as column names.F)
str_as_lit)r"   _extract_compliantappendr   itemsalias)r\   exprsnamed_exprs	out_exprs	out_kindsexprcompliant_exprro   s           r]   _flatten_and_extractBaseFrame._flatten_and_extracti   s     		END!44T:N^,Z?@ # ',,.KE!44T:@@GN^,Z?@ / ##r_   c                    [         erY   NotImplementedError)r\   args     r]   rl   BaseFrame._extract_complianty   s    !!r_   c                \    [        U R                  R                  R                  5       5      $ rY   )r   rU   schemarn   r[   s    r]   r~   BaseFrame.schema}   s"    d++2288:;;r_   c                ^    [        U R                  R                  5       5      n[        U5      $ rY   )dictrU   collect_schemar   )r\   native_schemas     r]   r   BaseFrame.collect_schema   s&    T22AACDm$$r_   c                    U" U /UQ70 UD6$ rY    )r\   functionargskwargss       r]   pipeBaseFrame.pipe   s     .t.v..r_   c                V    U R                  U R                  R                  U5      5      $ rY   )rh   rU   with_row_indexr\   names     r]   r   BaseFrame.with_row_index   s$    ##D$9$9$H$H$NOOr_   c                    [        U[        5      (       a  U/OUnU R                  U R                  R	                  US95      $ )Nsubset)
isinstancestrrh   rU   
drop_nulls)r\   r   s     r]   r   BaseFrame.drop_nulls   s<    '44&&##D$9$9$D$DF$D$STTr_   c                .    U R                   R                  $ rY   )rU   columnsr[   s    r]   r   BaseFrame.columns   s    $$,,,r_   c                   U R                   " U0 UD6u  p4[        X45       VVs/ s H(  u  pV[        U5      (       a  UR                  U5      OUPM*     nnnU R	                  U R
                  R                  " U6 5      $ s  snnf rY   )rv   zipr   	broadcastrh   rU   with_columns)r\   rp   rq   compliant_exprskindsru   kinds          r]   r   BaseFrame.with_columns   s     "&!:!:E!Q[!Q ),O(C
(C$ /=T.B.BN$$T*V(C 	 
 ##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u  pU(       a8  [        U0 UD6(       a(  U R                  U R                  R                  " U6 5      $ [        X5       V
Vs/ s H(  u  p[        U5      (       a  U
R                  U5      OU
PM*     nn
nU R                  U R                  R                   " U6 5      $ ! [         aG  nU R                  nU Vs/ s H  ofU;  d  M
  UPM     Os  snf nn[        R                  " Xu5      UeS nAff = fs  snn
f )Nc              3  B   #    U  H  n[        U[        5      v   M     g 7frY   )r   r   ).0xs     r]   	<genexpr>#BaseFrame.select.<locals>.<genexpr>   s     E*QjC00*s   )tupler"   allrh   rU   simple_select	Exceptionr   r   'from_missing_and_available_column_namesrv   r   	aggregater   r   r   select)r\   rp   rq   
flat_exprseavailable_columnsr   missing_columnsr   r   ru   r   s               r]   r   BaseFrame.select   s]   
 75>*
#E*EEEk
++))77D  "&!:!:J!V+!V8*TT''(=(=(G(G(YZZ ),O(C
(C$ /=T.B.BN$$T*V(C 	 
 ##D$9$9$@$@/$RSS  $(LL!.8"WjEV<V1j"W"W)QQ#	
s/   'D /E2
E/(E*8	EEE**E/c                V    U R                  U R                  R                  U5      5      $ rY   )rh   rU   rename)r\   mappings     r]   r   BaseFrame.rename   s$    ##D$9$9$@$@$IJJr_   c                V    U R                  U R                  R                  U5      5      $ rY   )rh   rU   headr\   ns     r]   r   BaseFrame.head   $    ##D$9$9$>$>q$ABBr_   c                V    U R                  U R                  R                  U5      5      $ rY   )rh   rU   tailr   s     r]   r   BaseFrame.tail   r   r_   c               R    U R                  U R                  R                  X!S95      $ )Nstrict)rh   rU   drop)r\   r   r   s      r]   r   BaseFrame.drop   s'    ##D$9$9$>$>w$>$VWWr_   c                  ^^	 [        U5      S:X  a  [        US   [        5      (       a  US   nOpSSKJm  [        U5      n[        USS06  U R                  5       m	U R                  " U6 u  pVUU	4S jUR                  5        5       nT	R                  " [        XW5      6 nU R                  U R                  R                  U5      5      $ )N   r   )colfunction_namefilterc              3  \   >#    U  H!  u  pT" U5      U:H  R                  T5      v   M#     g 7frY   )_to_compliant_expr)r   r   vr   plxs      r]   r   #BaseFrame.filter.<locals>.<genexpr>   s0      %2GD Ta33C882s   ),)lenr'   boolnarwhals.functionsr   r"   r   ra   rv   rn   all_horizontalr   rh   rU   r   )
r\   
predicatesconstraints	predicateflat_predicatescompliant_predicates_kindscompliant_constraintsr   r   s
           @@r]   r   BaseFrame.filter   s    
 z?aJz!}d$C$C"1I.%j1O-WhW--/C+/+D+Do+V( %*002%! **+CI ##D$9$9$@$@$KLLr_   F
descending
nulls_lastc                   [        / [        U/5      QUQ5      nU R                  U R                  R                  " XUS.65      $ )Nr   )r"   rh   rU   sort)r\   byr   r   more_bys        r]   r   BaseFrame.sort   sH     /wt}/w/0##!!&&jY
 	
r_   N_rightleft_onright_onsuffixc          
        [        U[        5      (       a  U/OUn[        U[        5      (       a  U/OUn[        U[        5      (       a  U/OUnUS=n;  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S:w  a  Uc  Ub  Uc  SU S3n[        U5      eUS:w  a  Ub  Uc  Ub  S	U S3n[        U5      eUb  U=pEU R	                  U R
                  R                  U R                  U5      UUUUS
9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 joinzGEither (`left_on` and `right_on`) or `on` keys should be specified for .zBIf `on` is specified, `left_on` and `right_on` should be None for )howr   r   r   )r   r   rz   
ValueErrorrh   rU   joinrl   )	r\   otheronr   r   r   r   _supported_joinsmsgs	            r]   r   BaseFrame.join   sT     C((bTb)'3777)W!+Hc!:!:H: RR
 GGWFXXabeaffhiC%c**'>8#72>RCS/!'>rzw(BR[\_[``abCS/!'>N 3x7KVWZV[[\]CS/!>!##G##!!&&''.! ' 
 	
r_   c                R    U R                  U R                  R                  XS95      $ )Nr   offset)rh   rU   gather_every)r\   r   r   s      r]   r   BaseFrame.gather_every  s,    ##!!...B
 	
r_   backwardr   r   r   by_leftby_rightr   strategyr   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/n[        U[        5      (       a  U/nU R	                  U R
                  R                  U R                  U5      UUUUUU	S	95      $ )
N)r  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.)r   r   r  r  r  r   )rz   r   r   r   rh   rU   	join_asofrl   )r\   r   r   r   r   r  r  r   r  r   _supported_strategiesr   s               r]   r	  BaseFrame.join_asof$  sN    !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gs##iGh$$ zH##!!++''.!!! , 

 
	
r_   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   rh   rU   unpivot)r\   r   r  r  r  s        r]   r  BaseFrame.unpivot\  s_      C((bTb%eS11u##!!))- * 
 	
r_   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)ry   r\   r   r   s      r]   __neq__BaseFrame.__neq__m      + 	 "#&&r_   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)ry   r  s      r]   __eq__BaseFrame.__eq__x  r  r_   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   rh   rU   explode)r\   r   more_columns
to_explodes       r]   r  BaseFrame.explode  sW     '3'' $|$*7*\* 	 ##D$9$9$A$A*$A$UVVr_   r   )returnr/   )r!  r   )rg   r   r!  r2   )rp   IntoExpr | Iterable[IntoExpr]rq   r@   r!  z8tuple[list[IntoCompliantExpr[Any, Any]], list[ExprKind]]r{   r   r!  r   r!  r   r   z"Callable[Concatenate[Self, PS], R]r   zPS.argsr   z	PS.kwargsr!  rQ   r  r   r   r!  r2   r   str | list[str] | Noner!  r2   r!  z	list[str]rp   r"  rq   r@   r!  r2   r   zdict[str, str]r!  r2   r   intr!  r2   )r   zIterable[str]r   r   r!  r2   r   z*IntoExpr | Iterable[IntoExpr] | list[bool]r   r   r!  r2   
r   str | Iterable[str]r   r   r   zbool | Sequence[bool]r   r   r!  r2   Nr   r   r2   r   r)  r   rB   r   r)  r   r)  r   r   r!  r2   r   r   r.  r   r.  r!  r2   r   r2   r   
str | Noner   r7  r   r7  r  r)  r  r)  r   r)  r  r>   r   r   r!  r2   
r   r)  r  r)  r  r   r  r   r!  r2   )r   objectr!  r   r   zstr | Sequence[str]r  r   r!  r2   )"__name__
__module____qualname____firstlineno____annotations__rZ   ra   rh   rv   r   rl   propertyr~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	  r  r  r  r  __static_attributes__r   r_   r]   rS   rS   [   s   22<>5$3$DL$	A$  " " < <%
/4/ / 	/
 
/PU - -Z3ZDLZ	ZT-T  T 
	T8KCCXM?M M 
	M6 -2 



 

 *	


 

 


 &*#	/
 +/+//
/
 #/
 	/
 (/
 )/
 /
 
/
b
 ##*.+/%)%/6
6
 	6

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

 
 
 

"	'	'Wr_   rS   c            	      N  ^  \ rS rSrSrSbS jr\ScS j5       r\SdS j5       rSeS jr	\SfS j5       r
SgS jrShSiS
 jjrSjS jrSkSlS jjr Sk   SmS jjrSnS jrSoS jrSpS jr\SkSqS jj5       r\SrS j5       rSkSsS jjrSrS jrStS jr\SuS j5       rSvS jrSwSxS jjr\SyS j5       r\    SzS j5       r\    S{S j5       r    S|S jrS}S jr\SS.S~S  jj5       r\SS! j5       r\    SS" j5       rS#S.   SS$ jjrSS% jr        SU 4S& jjrSkSU 4S' jjjrSSU 4S( jjjr \SU 4S) jj5       r!SU 4S* jjr"\SU 4S+ jj5       r#\S,S-.SS. jj5       r$\SS/ j5       r$\SS0 j5       r$S,S-.   SS1 jjr$SS2 jr%\SS3.     SS4 jj5       r&\SS3.     SS5 jj5       r&\SS3.     SS6 jj5       r&S,S7S8.     SS9 jjr&      SU 4S: jjr'      SU 4S; jjr(SU 4S< jjr)SSU 4S= jjjr*SSU 4S> jjjr+S#S?.SU 4S@ jjjr, SkSAS,SB.       SSC jjjr-      SU 4SD jjr.S,SE.     SSF jjr/S,S,SG.         SU 4SH jjjr0  SS	S	SISJ.             SU 4SK jjjjr1S	S	S	S	S	S	SLSISM.                   SU 4SN jjjr2SSO jr3SSP jr4SSQ jr5SSR jr6ShSSS jjr7SST jr8SSU 4SU jjjr9S	S	S	S	S,SVSW.               SSX jjr:SSY jr; SkS	S,S	SZ.         SS[ jjjr< SkS	S\S]S^.         SU 4S_ jjjjr=SU 4S` jjr>Sar?U =r@$ )	DataFramei  a2  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),
        )
        ```
c                   SSK Jn  SSKJn  U R	                  5       n[        U[        5      (       a  UR                  $ [        X5      (       a  UR                  R                  5       $ [        X5      (       a  UR                  U R	                  5       5      $ [        U[        5      (       a  UR                  U5      $ [        5       b2  S[        [        U5      5      ;   a  S[        U5       S3n[        U5      e[!        U5      (       a'  UR"                  R%                  XS9R                  5       $ [&        R(                  " [        U5      5      e)Nr   Exprr<   polarsExpected Narwhals object, got: [.

Perhaps you:
- Forgot a `nw.from_native` somewhere?
- Used `pl.col` instead of `nw.col`?)context)narwhals.exprrF  narwhals.seriesr=   ra   r   rS   rU   _compliant_series_to_exprr   r   r   r   type	TypeErrorr   _series
from_numpyr   from_invalid_type)r\   r{   rF  r=   r   r   s         r]   rl   DataFrame._extract_compliant  s   &*!%!<!<!>c9%%'''c""((1133c  ))$*E*E*GHHc3773<<#CS	N(B1$s) =7 7  C. #;;))#);DDFF"44T#Y??r_   c                    SSK Jn  U$ )Nr   r<   )rL  r=   )r\   r=   s     r]   rQ  DataFrame._series  s
    *r_   c                    [         $ rY   )	LazyFramer[   s    r]   
_lazyframeDataFrame._lazyframe      r_   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: )rW   r$   __narwhals_dataframe__rU   rO  AssertionErrorr\   rg   re   r   s       r]   __init__DataFrame.__init__  sE    >C!"%%$&$=$=$?D!WX\]_X`WabC %%r_   c                .    U R                   R                  $ )aG  Return implementation of native frame.

This can be useful when you need to use special-casing for features outside of
Narwhals' scope - for example, when dealing with pandas' Period Dtype.

Returns:
    Implementation.

Examples:
    >>> import narwhals as nw
    >>> import pandas as pd
    >>> df_native = pd.DataFrame({"a": [1, 2, 3]})
    >>> df = nw.from_native(df_native)
    >>> df.implementation
    <Implementation.PANDAS: 1>
    >>> df.implementation.is_pandas()
    True
    >>> df.implementation.is_pandas_like()
    True
    >>> df.implementation.is_polars()
    False
rU   _implementationr[   s    r]   implementationDataFrame.implementation  s    0 $$444r_   c                6    U R                   R                  5       $ rY   )rU   __len__r[   s    r]   rh  DataFrame.__len__  s    $$,,..r_   Nc                4    U R                   R                  XS9$ )Ncopy)rU   	__array__)r\   dtyperl  s      r]   rm  DataFrame.__array__  s    $$..u.@@r_   c                R    [        SU R                  5       R                  5       5      $ )NzNarwhals DataFramer#   r   __repr__r[   s    r]   rr  DataFrame.__repr__       14>>3C3L3L3NOOr_   c                ^   U R                   R                  n[        U5      (       a  UR                  US9$  SSKn[        U5      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_schemar   NzRPyArrow>=14.0.0 is required for `DataFrame.__arrow_c_stream__` for object of type )   r   )	rU   _native_framer,   __arrow_c_stream__pyarrowModuleNotFoundErrorrO  r+   to_arrow)r\   rv  native_framepaexcr   pa_tables          r]   ry  DataFrame.__arrow_c_stream__  s     ,,::"<0022DT2UU	4  w&fgklxgyfz{C%c*4==?**<L*MM # 	4fgklxgyfz{C%c*3	4s   B 
B,B''B,c                   Uc  SO[         R                  " U5      n[         R                  [         R                  [         R                  4nUb  X#;  a  SU SU 3n[        U5      eU R                  U R                  R                  US9SS9$ )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.

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`
            or `POLARS`.
        - As a string: `"dask"`, `"duckdb"` or `"polars"`
        - Directly as a module `dask.dataframe`, `duckdb` or `polars`.

Returns:
    A new LazyFrame.

Examples:
    >>> import polars as pl
    >>> import pyarrow as pa
    >>> 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 │ |
    |└───────┴───────┘ |
    └──────────────────┘
Nz(Not-supported backend.

Expected one of z or `None`, got )backendlazyrd   )	r    from_backendDASKDUCKDBPOLARSr   rY  rU   r  )r\   r  lazy_backendsupported_lazy_backendsr   s        r]   r  DataFrame.lazy  s    ~  'tN4O4OPW4X!!!!#

 #(S''>&??OP\~_  S/!!!&&|&<F  
 	
r_   c                .    U R                   R                  $ )a  Convert Narwhals DataFrame to native one.

Returns:
    Object of class that user started with.

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
)rU   rx  r[   s    r]   r   DataFrame.to_native\  s    * $$222r_   c                6    U R                   R                  5       $ )a  Convert this DataFrame to a pandas DataFrame.

Returns:
    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
)rU   	to_pandasr[   s    r]   r  DataFrame.to_pandass  s    & $$..00r_   c                6    U R                   R                  5       $ )u#  Convert this DataFrame to a polars DataFrame.

Returns:
    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 │
    └─────┴─────┘
)rU   	to_polarsr[   s    r]   r  DataFrame.to_polars  s    , $$..00r_   c                    g rY   r   r\   files     r]   	write_csvDataFrame.write_csv  s    36r_   c                    g rY   r   r  s     r]   r  r    s    =@r_   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.

Returns:
    String or None.

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()
    '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.
)rU   r  r  s     r]   r  r    s    . $$..t44r_   c                :    U R                   R                  U5        g)a  Write dataframe to parquet file.

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

Returns:
    None.

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)rU   write_parquetr  s     r]   r  DataFrame.write_parquet  s    " 	++D1r_   c                6    U R                   R                  SSS9$ )aF  Convert this DataFrame to a NumPy ndarray.

Returns:
    A NumPy ndarray array.

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. ]])
Nrk  )rU   to_numpyr[   s    r]   r  DataFrame.to_numpy  s      $$--d->>r_   c                .    U R                   R                  $ )a  Get the shape of the DataFrame.

Returns:
    The shape of the dataframe as a tuple.

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)
)rU   shaper[   s    r]   r  DataFrame.shape  s     $$***r_   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.

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

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
rd   )rQ  rU   
get_columnrW   r   s     r]   r  DataFrame.get_column  s,    4 ||D11<<TB$++|VVr_   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'.

Returns:
    Integer or Float.

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)rU   estimated_size)r\   r  s     r]   r  DataFrame.estimated_size  s    ( $$333>>r_   c                    g rY   r   r\   items     r]   __getitem__DataFrame.__getitem__(  s    WZr_   c                    g rY   r   r  s     r]   r  r  +  s     r_   c                    g rY   r   r  s     r]   r  r  0  s     r_   c                2   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[        [        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[['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'`.

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

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   r<   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, :]`?Nr   )rL  r=   rO  r   r   r   rP  r)   r&   r(   slicer   rU   r.  r  r   r  rM  rh   )
r\   r  r=   r   	tuple_msgrowsr   	compliantcol_nameseriess
             r]   r  r  ;  s   | 	+ 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. ))	gSz**$$$yy//",Wc":":wW@UH__X.F#'#36<??d##))Dg&&//G<''	!W*(=>>?''	'(:;;##IGm$<==r_   c                    XR                   ;   $ rY   r  )r\   keys     r]   __contains__DataFrame.__contains__  s    ll""r_   .	as_seriesc                   g rY   r   r\   r  s     r]   to_dictDataFrame.to_dict      TWr_   c                   g rY   r   r  s     r]   r  r    s    MPr_   c                   g rY   r   r  s     r]   r  r    s     9<r_   Tc          
         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.

Returns:
    A mapping from column name to values / Series.

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  rd   )rU   r  rn   rQ  rW   )r\   r  r  values       r]   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.

Returns:
    A tuple of the values in the selected row.

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)
    (<pyarrow.Int64Scalar: 2>, <pyarrow.Int64Scalar: 5>)
)rU   row)r\   r  s     r]   r  DataFrame.row  s    0 $$((//r_   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.

Returns:
    The original object with the function applied.

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   r\   r   r   r   rf   s       r]   r   DataFrame.pipe  s    : w|H6t6v66r_   c                   > [         TU ]  US9$ )a  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.

Returns:
    The original object with the rows removed that contained the null values.

Notes:
    pandas handles null values differently from Polars and PyArrow.
    See [null_handling](../pandas_like_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   r\   r   rf   s     r]   r   DataFrame.drop_nulls  s    6 w!!00r_   c                "   > [         TU ]  U5      $ )a  Insert column which enumerates rows.

Arguments:
    name: The name of the column as a string. The default is "index".

Returns:
    The original object with the column added.

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   rf   s     r]   r   DataFrame.with_row_index+  s    . w%d++r_   c                   > [         TU ]  $ )ah  Get an ordered mapping of column names to their data type.

Returns:
    A Narwhals Schema object that displays the mapping of column names.

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~   r\   rf   s    r]   r~   DataFrame.schemaD       w~r_   c                    > [         TU ]  5       $ )ar  Get an ordered mapping of column names to their data type.

Returns:
    A Narwhals Schema object that displays the mapping of column names.

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    r]   r   DataFrame.collect_schemaT       w%''r_   c                   > [         TU ]  $ )a  Get column names.

Returns:
    The column names stored in a list.

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    r]   r   DataFrame.columnsc       wr_   Fnamedc                   g rY   r   r\   r  s     r]   r  DataFrame.rowss  s    ORr_   c                   g rY   r   r  s     r]   r  r  v  s    EHr_   c                   g rY   r   r  s     r]   r  r  y  r  r_   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.

Returns:
    The data as a list of rows.

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  )rU   r  r  s     r]   r  r  |  s    ( $$)))66r_   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|
    └─────────────────────────┘
rd   N)rU   iter_columnsrQ  rW   )r\   r  s     r]   r  DataFrame.iter_columns  s5     8 ++88:F,,v[[,99 ;s   >A )buffer_sizec                   g rY   r   r\   r  r  s      r]   	iter_rowsDataFrame.iter_rows  s     %(r_   c                   g rY   r   r  s      r]   r  r    s     $'r_   c                   g rY   r   r  s      r]   r  r    s	     @Cr_   i   r  r  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

Returns:
    An iterator over the DataFrame of rows.

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  )rU   r  r  s      r]   r  r    s    : $$..U.TTr_   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.

Returns:
    DataFrame: A new DataFrame with the columns added.

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   r\   rp   rq   rf   s      r]   r   DataFrame.with_columns  s    F w#U:k::r_   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.

Returns:
    The dataframe containing only the selected columns.

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   r  s      r]   r   DataFrame.select  s    D w~u444r_   c                "   > [         TU ]  U5      $ )a  Rename column names.

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

Returns:
    The dataframe with the specified columns renamed.

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   r\   r   rf   s     r]   r   DataFrame.rename(  s    * w~g&&r_   c                "   > [         TU ]  U5      $ )a  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)`.

Returns:
    A subset of the dataframe of shape (n, n_columns).

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   r\   r   rf   s     r]   r   DataFrame.head?  s    $ w|Ar_   c                "   > [         TU ]  U5      $ )um  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)`.

Returns:
    A subset of the dataframe of shape (n, n_columns).

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     r]   r   DataFrame.tailS      , w|Ar_   r   c               6   > [         TU ]  " [        U5      SU06$ )ag  Remove columns from the dataframe.

Returns:
    The dataframe with the specified columns removed.

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"   r\   r   r   rf   s      r]   r   DataFrame.dropk  s    , w|WW-=f==r_   anykeepmaintain_orderc                   US;  a  SS SU 3n[        U5      e[        U[        5      (       a  U/nU R                  U R                  R                  XUS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.

Returns:
    The dataframe with the duplicate rows removed.

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
>   r  lastnonefirstz	Expected )r  r  r  r  z, got: r  r   r   r   rh   rU   unique)r\   r   r  r  r   s        r]   r  DataFrame.unique  sl    F 77<=WTFKCS/!fc""XF##!!((>(Z
 	
r_   c                $   > [         TU ]  " 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 (single!) boolean list.
    **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 &.

Returns:
    The filtered dataframe.

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
)r  r   )r\   r   r   rf   s      r]   r   DataFrame.filter  s    p w~z9[99r_   drop_null_keysc                  ^^ SSK Jm  SSKJn  SSKJm  [        U5      n[        UU4S jU 5       5      (       a  Sn[        U5      eU" U /UQ7SU06$ )as  Start a group by operation.

Arguments:
    *keys: Column(s) to group by. Accepts multiple columns names as a list.
    drop_null_keys: if True, then groups where any key is null won't be included
        in the result.

Returns:
    GroupBy: Object which can be used to perform aggregations.

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
r   rE  r8   r<   c              3  @   >#    U  H  n[        UTT45      v   M     g 7frY   r   r   r   rF  r=   s     r]   r   %DataFrame.group_by.<locals>.<genexpr>       @iz!dF^,,i   `group_by` with expression or Series keys is not (yet?) supported.

Hint: instead of `df.group_by(nw.col('a'))`, use `df.group_by('a')`.r  )	rK  rF  narwhals.group_byr9   rL  r=   r"   r  rz   )r\   r  keysr9   	flat_keysr   rF  r=   s         @@r]   group_byDataFrame.group_by  sV    b 	'-*DM	@i@@@W  &c**tGiGGGr_   r   c               ,   > [         TU ]  " U/UQ7X#S.6$ )u4  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.

Returns:
    The sorted dataframe.

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   r\   r   r   r   r   rf   s        r]   r   DataFrame.sort'  s    N w|BWWZWWr_   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.

Returns:
    A new joined DataFrame

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   r\   r   r   r   r   r   r   rf   s          r]   r   DataFrame.joinP  s#    Z w|G2  
 	
r_   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.

Both DataFrames must be sorted by the asof_join key.

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.

Returns:
    A new joined DataFrame

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  r	  r\   r   r   r   r   r  r  r   r  r   rf   s             r]   r	  DataFrame.join_asof  s8    R w  ! 

 
	
r_   c                $    U R                  5       ) $ )u	  Get a mask of all duplicated rows in this DataFrame.

Returns:
    A new Series.

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_uniquer[   s    r]   is_duplicatedDataFrame.is_duplicated  s    (    r_   c                    [        U 5      S:H  $ )aC  Check if the dataframe is empty.

Returns:
    A boolean indicating whether the dataframe is empty (True) or not (False).

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   r[   s    r]   is_emptyDataFrame.is_empty  s     4yA~r_   c                f    U R                  U R                  R                  5       U R                  S9$ )u  Get a mask of all unique rows in this DataFrame.

Returns:
    A new Series.

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  |
    └───────────────┘
rd   )rQ  rU   r9  rW   r[   s    r]   r9  DataFrame.is_unique  s*    ( ||D11;;=T[[|QQr_   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.

Returns:
    A dataframe of shape (1, n_columns).

Notes:
    pandas handles null values differently from Polars and PyArrow.
    See [null_handling](../pandas_like_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]]      |
    └──────────────────┘
)rU   ra   r   r   
null_countrh   )r\   r   results      r]   rB  DataFrame.null_count  sN    6 ##::<&&--cggi.B.B.DE##F++r_   c                4    U R                   R                  XS9$ )aZ  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).

Returns:
    A scalar or the specified element in the dataframe.

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)rU   r  )r\   r  rF  s      r]   r  DataFrame.item1  s    * $$))c)AAr_   c                T    U R                  U R                  R                  5       5      $ )z\Create a copy of this DataFrame.

Returns:
    An identical copy of the original dataframe.
)rh   rU   cloner[   s    r]   rI  DataFrame.cloneH  s$     ##D$9$9$?$?$ABBr_   c                   > [         TU ]  XS9$ )u  Take every nth row in the DataFrame and return as a new DataFrame.

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

Returns:
    The dataframe containing only the selected rows.

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   )r\   r   r   rf   s      r]   r   DataFrame.gather_everyP  s    0 w#a#77r_   _)r  valuesaggregate_functionr  sort_columns	separatorc               V   Uc  Uc  Sn[        U5      eUb  Sn[        U[        [        5       S9  [	        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.

Returns:
    A new dataframe.

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.)messagecategory
stacklevel)r   r  rN  rO  rP  rQ  )	r   r   UserWarningr!   r   r   rh   rU   pivot)	r\   r   r  rN  rO  r  rP  rQ  r   s	            r]   rW  DataFrame.pivotj  s    t >emGCS/!%7  {?PQC((bTb'44&&%eS11u##!!''#5)# ( 	
 		
r_   c                6    U R                   R                  5       $ )aP  Convert to arrow table.

Returns:
    A new PyArrow 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]]
)rU   r|  r[   s    r]   r|  DataFrame.to_arrow  s    $ $$--//r_   )fractionwith_replacementseedc          	     T    U R                  U R                  R                  XX4S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.

Returns:
    A new dataframe.

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[  r\  r]  )rh   rU   sample)r\   r   r[  r\  r]  s        r]   r_  DataFrame.sample  s7    H ##!!((9I ) 
 	
r_   variabler  r  r  r  c                   > [         TU ]  XX4S9$ )ur  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".

Returns:
    The unpivoted dataframe.

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  r\   r   r  r  r  rf   s        r]   r  DataFrame.unpivot  s!    l wm  
 	
r_   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.

Returns:
    New DataFrame

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  r  r\   r   r  rf   s      r]   r  DataFrame.explode4  s    > ww666r_   rU   rW   r#  )r!  ztype[Series[Any]])r!  ztype[LazyFrame[Any]]rg   r   re   rV   r!  Noner!  r    )r!  r.  )NN)rn  r   rl  bool | Noner!  rK   r!  r   rY   )rv  zobject | Noner!  r9  )r  (ModuleType | Implementation | str | Noner!  zLazyFrame[Any])r!  rP   )r!  zpd.DataFrame)r!  zpl.DataFrame)r  rm  r!  r   )r  zstr | Path | BytesIOr!  rm  )r  zstr | Path | BytesIO | Noner!  r7  )r!  rK   )r!  ztuple[int, int])r   r   r!  Series[Any])b)r  rI   r!  zint | float)r  z-tuple[SingleIndexSelector, SingleColSelector]r!  r   )r  z2str | tuple[MultiIndexSelector, SingleColSelector]r!  rr  )r  zSingleIndexSelector | MultiIndexSelector | MultiColSelector | tuple[SingleIndexSelector, MultiColSelector] | tuple[MultiIndexSelector, MultiColSelector]r!  r2   )r  a  SingleIndexSelector | SingleColSelector | MultiColSelector | MultiIndexSelector | tuple[SingleIndexSelector, SingleColSelector] | tuple[SingleIndexSelector, MultiColSelector] | tuple[MultiIndexSelector, SingleColSelector] | tuple[MultiIndexSelector, MultiColSelector]r!  zSeries[Any] | Self | Any)r  r   r!  r   )r  Literal[True]r!  zdict[str, Series[Any]])r  Literal[False]r!  zdict[str, list[Any]])r  r   r!  z-dict[str, Series[Any]] | dict[str, list[Any]])r  r.  r!  ztuple[Any, ...]r%  r(  r&  r'  r$  r*  )r  ru  r!  zlist[tuple[Any, ...]])r  rt  r!  zlist[dict[str, Any]])r  r   r!  z,list[tuple[Any, ...]] | list[dict[str, Any]])r!  zIterator[Series[Any]])r  ru  r  r.  r!  zIterator[tuple[Any, ...]])r  rt  r  r.  r!  zIterator[dict[str, Any]])r  r   r  r.  r!  z4Iterator[tuple[Any, ...]] | Iterator[dict[str, Any]]r+  r,     r-  r   r1  r   r   r!  r2   )r   r)  r  rJ   r  r   r!  r2   r/  )r'  r1  r  r   r!  zGroupBy[Self]r0  r2  r3  r6  )r!  rr  )r!  r   r!  r2   )r  
int | NonerF  zint | str | Noner!  r   r4  r5  )r   zstr | list[str]r  r)  rN  r)  rO  zPivotAgg | Noner  ro  rP  r   rQ  r   r!  r2   )r!  zpa.Table)
r   rz  r[  zfloat | Noner\  r   r]  rz  r!  r2   r8  r:  )Ar;  r<  r=  r>  __doc__rl   r@  rQ  rY  r`  re  rh  rm  rr  ry  r  r   r  r  r   r  r  r  r  r  r  r  r  r  r  r   r   r   r~   r   r   r  r  r  r   r   r   r   r   r   r  r   r)  r   r   r	  r:  r=  r9  rB  r  rI  r   rW  r|  r_  r  r  rA  __classcell__rf   s   @r]   rC  rC    s   0@2  
  & 5 52/APN2 =AM
9M
 
M
^3.1*10 6 6@ @522&?" + + W8?0 Z ZF	  	:	 
	 	o>:o> 
"o>b# 47W WP P< <	6< < $(B B	6B:06747 7 	7
 
7>1 1:, ,2  (   .3R RH HW W  %77	57,:> ;>(&(58(	"( ( :='%'47'	!' ' 14CC+.C	=C C
  %UU36U	=U>#;3#;DL#;	#;J"5-"5  "5 
	"5H'. ( 0 BF > >4 *.*
 $)$*
&*
 !	*

 *
 
*
X8:?8: 8: 
	8:v BG<H(<H:><H	<HD -2 'X'X 'X *	'X
 'X 
'X 'XX &*#	/
 +/+//
/
 #/
 	/
 (/
 )/
 /
 
/
 /
j ##*.+/%)%/S
S
 	S

 S
 S
 (S
 )S
 #S
 #S
 S
 
S
 S
l!,R,,>B.C8 8< )-)-.2&*"P
P
 &	P

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

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

 8
 8
 
8
 8
t7 7r_   rC  c            	        ^  \ rS rSrSrS1S jr\S2S j5       rS3S jrS4S jr	\S5S j5       r
S6S jr S7     S8S
 jjrS9S jr        S:U 4S jjrS7S;U 4S jjjrS<S=U 4S jjjr\S>U 4S jj5       rS>U 4S jjr\S?U 4S jj5       r      S@U 4S jjr      S@U 4S jjrSAU 4S jjrSBSCU 4S jjjrSBSCU 4S jjjrSS.SDU 4S jjjr S7SS.     SES jjjr      SFU 4S jjrSS.     SGS  jjrSSS!.         SHU 4S" jjjr  SIS	S	S#S$.             SJU 4S% jjjjrS	S	S	S	S	S	S&S#S'.                   SKU 4S( jjjrSLS) jr SMSNU 4S* jjjr! S7S	S+S,S-.         SOU 4S. jjjjr"SPU 4S/ jjr#S0r$U =r%$ )QrX  iV  as  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)
    ```
c                   SSK Jn  SSKJn  [	        U[
        5      (       a  UR                  $ [	        X5      (       a  Sn[        U5      e[	        U[        5      (       a!  U R                  5       nUR                  U5      $ [	        X5      (       a  UR                  R                  R                  5       (       a  Sn[        U5      eUR                  R                  R!                  5       (       a  Sn[#        U5      eUR%                  U R                  5       5      $ ['        5       b2  S[        [)        U5      5      ;   a  S[)        U5       S	3n[        U5      e[*        R,                  " [)        U5      5      e)
Nr   rE  r<   zABinary operations between Series and LazyFrame are not supported.aN  Order-dependent expressions are not supported for use in LazyFrame.

Hints:
- Instead of `lf.select(nw.col('a').sort())`, use `lf.select('a').sort()`.
- Instead of `lf.select(nw.col('a').cum_sum())`, use
  `lf.select(nw.col('a').cum_sum().over(order_by='date'))`.

See https://narwhals-dev.github.io/narwhals/basics/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())
rG  rH  rI  )rK  rF  rL  r=   r   rS   rU   rP  r   ra   r   	_metadata_window_kindis_openr   r   is_filtrationr   r   r   rO  r   rS  )r\   r{   rF  r=   r   r   s         r]   rl   LazyFrame._extract_compliantc  s=   &*c9%%'''c""UCC. c3--/C773<c  }}))1133\  .c22}}!!//11I  .c22))$*E*E*GHH<#CS	N(B1$s) =7 7  C. "44T#Y??r_   c                    [         $ rY   )rC  r[   s    r]   
_dataframeLazyFrame._dataframe  r[  r_   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: )rW   r%   __narwhals_lazyframe__rU   rO  r^  r_  s       r]   r`  LazyFrame.__init__  sE    !"%%$&$=$=$?D!jkoprksjtuC %%r_   c                R    [        SU R                  5       R                  5       5      $ )NzNarwhals LazyFramerq  r[   s    r]   rr  LazyFrame.__repr__  rt  r_   c                .    U R                   R                  $ )a  Return implementation of native frame.

This can be useful when you need to use special-casing for features outside of
Narwhals' scope - for example, when dealing with pandas' Period Dtype.

Returns:
    Implementation.

Examples:
    >>> import narwhals as nw
    >>> import dask.dataframe as dd
    >>> lf_native = dd.from_dict({"a": [1, 2]}, npartitions=1)
    >>> nw.from_native(lf_native).implementation
    <Implementation.DASK: 7>
rc  r[   s    r]   re  LazyFrame.implementation  s    " $$444r_   c                    Sn[        U5      e)Nz%Slicing is not supported on LazyFrame)rP  )r\   r  r   s      r]   r  LazyFrame.__getitem__  s    5nr_   Nc                &   Uc  SO[         R                  " U5      n[         R                  [         R                  [         R                  4nUb  X4;  a  SU SU S3n[        U5      eU R                  U R                  R                  " SSU0UD6SS9$ )	uM	  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)

Returns:
    DataFrame

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]]      |
    └──────────────────┘
Nz-Unsupported `backend` value.
Expected one of z or None, got: r   r  r   rd   r   )	r    r  r  PANDASPYARROWr   r  rU   collect)r\   r  r   eager_backendsupported_eager_backendsr   s         r]   r  LazyFrame.collect  s    B !(^5P5PQX5Y!!!!""$
 
 $)VBC[B\\klykzz{|CS/!!!))J-J6J  
 	
r_   c                    [        U SS9$ )uD  Convert Narwhals LazyFrame to native one.

Returns:
    Object of class that user started with.

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_throughr   r[   s    r]   r   LazyFrame.to_native	  s    ( EBBr_   c                ,   > [         TU ]  " U/UQ70 UD6$ )uw  Pipe function call.

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

Returns:
    The original object with the function applied.

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       r]   r   LazyFrame.pipe	  s    < w|H6t6v66r_   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.

Returns:
    The original object with the rows removed that contained the null values.

Notes:
    pandas handles null values differently from Polars and PyArrow.
    See [null_handling](../pandas_like_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     r]   r   LazyFrame.drop_nulls<	  s    > w!!00r_   c                "   > [         TU ]  U5      $ )u  Insert column which enumerates rows.

Arguments:
    name: The name of the column as a string. The default is "index".

Returns:
    The original object with the column added.

Examples:
    >>> import dask.dataframe as dd
    >>> import narwhals as nw
    >>> lf_native = dd.from_dict({"a": [1, 2], "b": [4, 5]}, npartitions=1)
    >>> nw.from_native(lf_native).with_row_index().collect()
    ┌──────────────────┐
    |Narwhals DataFrame|
    |------------------|
    |     index  a  b  |
    |  0      0  1  4  |
    |  1      1  2  5  |
    └──────────────────┘
r  r  s     r]   r   LazyFrame.with_row_index]	  s    , w%d++r_   c                   > [         TU ]  $ )an  Get an ordered mapping of column names to their data type.

Returns:
    A Narwhals Schema object that displays the mapping of column names.

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
    Schema({'a': Int32, 'b': Decimal})
r  r  s    r]   r~   LazyFrame.schemau	  r  r_   c                    > [         TU ]  5       $ )ax  Get an ordered mapping of column names to their data type.

Returns:
    A Narwhals Schema object that displays the mapping of column names.

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})
r  r  s    r]   r   LazyFrame.collect_schema	  r  r_   c                   > [         TU ]  $ )a  Get column names.

Returns:
    The column names stored in a list.

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    r]   r   LazyFrame.columns	  r  r_   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.

Returns:
    LazyFrame: A new LazyFrame with the columns added.

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   r\   rp   rq   r   rf   s       r]   r   LazyFrame.with_columns	  s/    N [TCS/!w#U:k::r_   c                Z   > U(       d  U(       d  Sn[        U5      e[        TU ]  " U0 UD6$ )u  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.

Returns:
    The LazyFrame containing only the selected columns.

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       r]   r   LazyFrame.select	  s.    N [NCS/!w~u444r_   c                "   > [         TU ]  U5      $ )u2  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.

Returns:
    The LazyFrame with the specified columns renamed.

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 │|
    |└───────┴──────────────┘|
    └────────────────────────┘
r   r  s     r]   r   LazyFrame.rename	  s    8 w~g&&r_   c                "   > [         TU ]  U5      $ )uN  Get `n` rows.

Arguments:
    n: Number of rows to return.

Returns:
    A subset of the LazyFrame of shape (n, n_columns).

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     r]   r   LazyFrame.head
  r
  r_   c                "   > [         TU ]  U5      $ )aZ  Get the last `n` rows.

!!! warning
    `LazyFrame.tail` is deprecated and will be removed in a future version.
    Note: this will remain available in `narwhals.stable.v1`.
    See [stable api](../backcompat.md/) for more information.

Arguments:
    n: Number of rows to return.

Returns:
    A subset of the LazyFrame of shape (n, n_columns).
r  r  s     r]   r   LazyFrame.tail2
  s     w|Ar_   Tr   c               6   > [         TU ]  " [        U5      SU06$ )uP  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.

Returns:
    The LazyFrame with the specified columns removed.

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   r  r  s      r]   r   LazyFrame.dropB
  s    < w|WW-=f==r_   r  )r  c                   US;  a  SU S3n[        U5      e[        U[        5      (       a  U/nU R                  U R                  R                  XS95      $ )uK  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'}
        Which of the duplicate rows to keep.

        * 'any': Does not give any guarantee of which row is kept.
        * 'none': Don't keep duplicate rows.

Returns:
    The LazyFrame with unique rows.

Examples:
    >>> import duckdb
    >>> import narwhals as nw
    >>> lf_native = duckdb.sql("SELECT * FROM VALUES (1, 1), (3, 4) df(a, b)")
    >>> nw.from_native(lf_native).unique("a").sort("a", descending=True)
    ┌──────────────────┐
    |Narwhals LazyFrame|
    |------------------|
    |┌───────┬───────┐ |
    |│   a   │   b   │ |
    |│ int32 │ int32 │ |
    |├───────┼───────┤ |
    |│     3 │     4 │ |
    |│     1 │     1 │ |
    |└───────┴───────┘ |
    └──────────────────┘
>   r  r  z}narwhals.LazyFrame makes no assumptions about row order, so only 'any' and 'none' are supported for `keep` in `unique`. Got: r   )r   r  r  )r\   r   r  r   s       r]   r  LazyFrame.uniqueb
  sp    J &OOSfTUW  S/!fc""XF##!!(((B
 	
r_   c                   > [        U5      S:X  a,  [        US   [        5      (       a  U(       d  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 that evaluates to a boolean Series. Can
        also be a (single!) boolean list.
    **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 &.

Returns:
    The filtered LazyFrame.

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>
r   r   zX`LazyFrame.filter` is not supported with Python boolean masks - use expressions instead.)r   r'   r   rP  r  r   )r\   r   r   r   rf   s       r]   r   LazyFrame.filter
  sG    b 
Oq Z
1t%D%D[lCC. w~z9[99r_   Fr  c                  ^^ SSK Jm  SSKJn  SSKJm  [        U5      n[        UU4S jU 5       5      (       a  Sn[        U5      eU" U /UQ7SU06$ )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.

Returns:
    Object which can be used to perform aggregations.

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>
r   rE  r:   r<   c              3  @   >#    U  H  n[        UTT45      v   M     g 7frY   r   r!  s     r]   r   %LazyFrame.group_by.<locals>.<genexpr>  r#  r$  r%  r  )	rK  rF  r&  r;   rL  r=   r"   r  rz   )r\   r  r'  r;   r(  r   rF  r=   s         @@r]   r)  LazyFrame.group_by
  sV    @ 	'1*DM	@i@@@W  &c**4K)KNKKr_   r   c               ,   > [         TU ]  " U/UQ7X#S.6$ )u9  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.

Returns:
    The sorted LazyFrame.

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   r,  r-  s        r]   r   LazyFrame.sort  s    \ w|BWWZWWr_   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.

Returns:
    A new joined LazyFrame.

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       │|
    |└───────┴─────────┴─────────┘|
    └─────────────────────────────┘
r0  r1  r2  s          r]   r   LazyFrame.joinH  s#    l w|G2  
 	
r_   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.

Both DataFrames must be sorted by the asof_join key.

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.

Returns:
    A new joined LazyFrame.

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  r5  r6  s             r]   r	  LazyFrame.join_asof  s8    X w  ! 

 
	
r_   c                    U $ )zRestrict available API methods to lazy-only ones.

This is a no-op, and exists only for compatibility with `DataFrame.lazy`.

Returns:
    A LazyFrame.
r   r[   s    r]   r  LazyFrame.lazy  s	     r_   c                6   > Sn[        USS9  [        TU ]	  XS9$ )a  Take every nth row in the DataFrame and return as a new DataFrame.

!!! warning
    `LazyFrame.gather_every` is deprecated and will be removed in a future version.
    Note: this will remain available in `narwhals.stable.v1`.
    See [stable api](../backcompat.md/) for more information.

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

Returns:
    The LazyFrame containing only the selected rows.
z`LazyFrame.gather_every` is deprecated and will be removed in a future version.

Note: this will remain available in `narwhals.stable.v1`.
See https://narwhals-dev.github.io/narwhals/backcompat/ for more information.
z1.29.0)_versionr   )r*   r  r   )r\   r   r   r   rf   s       r]   r   LazyFrame.gather_every  s-     ^ 	
 	"#9w#a#77r_   ra  r  rb  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".

Returns:
    The unpivoted LazyFrame.

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  rd  re  s        r]   r  LazyFrame.unpivot  s!    j wm  
 	
r_   c                &   > [         TU ]  " U/UQ76 $ )ub  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.

Returns:
    New LazyFrame

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>
rh  ri  s      r]   r  LazyFrame.explode5  s    F ww666r_   rk  r#  )r!  ztype[DataFrame[Any]]rl  rp  rn  )r  zstr | slicer!  r   rY   )r  rq  r   r   r!  zDataFrame[Any])r!  rO   r%  r(  r&  r'  r$  r*  r+  r,  rv  r-  rx  )r   r)  r  rC   r!  r2   r/  )r'  r1  r  r   r!  zLazyGroupBy[Self]r0  r2  r3  r6  ry  r4  r5  r8  r:  )&r;  r<  r=  r>  r{  rl   r@  r  r`  rr  re  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  rA  r|  r}  s   @r]   rX  rX  V  s   
*@X  &P 5 5$ =AM
9M
 M
 
	M
^C.747 7 	7
 
7@1 1B, ,0  (  *;3*;DL*;	*;X*5-*5  *5 
	*5X'< 0   BF > >D *./
 (-	/
&/
 %	/

 
/
bV:?V: V: 
	V:r BG+L(+L:>+L	+Lb -2 .X.X .X *	.X
 .X 
.X .Xf &*#	8
 +/+/8
8
 #8
 	8
 (8
 )8
 8
 
8
 8
| ##*.+/%)%/V
V
 	V

 V
 V
 (V
 )V
 #V
 #V
 V
 
V
 V
p8 84 &*7
 )-'!7
"7
 &	7

 7
 7
 
7
 7
r#7 #7r_   rX  )j
__future__r   abcr   	itertoolsr   typingr   r   r   r	   r
   r   r   r   r   r   r   warningsr   narwhals._expression_parsingr   r   r   r   r   narwhals.dependenciesr   r   narwhals.exceptionsr   r   r   r   narwhals.schemar   narwhals.translater   narwhals.utilsr    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   ior-   pathlibr.   typesr/   pandaspdrG  plrz  r~  typing_extensionsr0   r1   r2   r3   narwhals._compliantr4   r5   r6   narwhals._compliant.typingr7   r&  r9   r;   rL  r=   narwhals.typingr>   r?   r@   rA   rB   rC   rD   _MultiColSelectorrE   _MultiIndexSelectorrF   rG   rH   rI   rJ   rK   rL   rM   rO   rP   rQ   r?  rS   rC  rX  r   r_   r]   <module>r     si   "                1 B J 3 7 , 0 3 4 7 7 " ( ) * " ( 1 1 , % + ( 4 ( 2 -+&+665<)-&0-(),6EI(13(2(	4B
);
/		-\9
CL> ) > B I BoW  oWd	F7	*% F7R6B7	&! B7r_   