
    Lpj#                      % S SK Jr  S SKrS SKrS SKrS SKJrJrJrJ	r	J
r
JrJr  S SKJr  S SKJrJr  S SKJrJrJr  S SKJr  S SKJrJr  S S	KJr  S S
KJr  S SKJ r   S SK!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*  S SK+J,r,  S SK-J.r.  S SK/J0r0J1r1  S SK2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>J?r?J@r@JArAJBrBJCrCJDrDJErE  S SKFJGrGJHrHJIrIJJrJ  \"(       GaP  S SKJKrK  S SKLJMrM  S SK!JNrNJOrO  S SKPrQS SKRrSS SKTrUS SKVJWrWJXrXJYrYJZrZ  S SK[J\r\J]r]J^r^  S SK_J`r`  S SKaJbrbJcrcJdrdJere  S SKfJgrg  S SKhJiriJjrjJkrkJlrlJmrmJnrnJoroJprpJqrqJrrrJsrsJtrt  S SKuJvrvJwrwJxrx  S SKyJzrzJ{r{J|r|J}r}J~r~JrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJrJr  S SKJr  S SKJr  S S KJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJr  \(" S!\\#   \\#   -  \\#   -  S"9r\(" S#5      r\(" S$5      r\(" S%5      r\(" S&S'S"9r\X" S(5      r\(" S)5      r\(" S*5      r\(" S+5      r " S, S-\'5      r " S. S/\'5      r " S0 S1\'5      r\(" S25      r\(" S3S4S59r\(" S6S4S59rS7rS8\S9'   \(" S:\S"9rS;rS8\S<'   S=rS8\S>'    " S? S@\'\   5      r " SA SB\'\   5      r " SC SD\'5      r " SE SF\'5      r " SG SH\'5      r " SI SJ\\\'5      r " SK SL\\\'5      r " SM SN\\'5      r " SO SP\5      r\" SQSR9SSS j5       r\" SQSR9SST j5       r\" SQSR9SSU j5       r\" SQSR9SSV j5       r\" SQSR9SSW j5       r " SX SY\,5      rSSZ jr\GR                  S[\GR                  S\\GR                  S]\GR                  S^\GR                  S_\GR                  S_\GR                  S`\GR                  Sa\GR                  Sb\GR                  Sc\GR                  Sd0rSe\Sf'   \GR                  Sg\GR                  Sh\GR                  Si\GR                  Sj0rSk\Sl'    \" SmSR9SSn j5       r\SSo j5       rSSp jrSSq jrSSr jrSSs jrSSt jr\*      SSu j5       r\*      SSv j5       r\*      SSw j5       r\*      SSx j5       r\*      SSy j5       r\*      SSz j5       r\*      SS{ j5       rSS| jrSS} jr      SS~ jrSS jr SSS.       SS jjjrSS jrSS jr      SS jr        SS jrSS jrSS jr S       SS jjr S       SS jjr        SS jrSS jrSS jrSS jr    SS jr    SS jrSS jrGS S jrGSS jr    GSS jr    GSS jrGSS jr    GSS jrGSS jrGSS jr        GSS jrSSS.     GS	S jjr      GS
S jr          GSS jrGSS jr      GSS jGr GSS jGr      GSS jGr          GSS jGrGSS jGrGSS jGrGSS jGrG\" 5       GrS\S'   GSS jGr	    GSS jGr
    GSS jGr    GSS jGr    GSS jGr    GSS jGrGSS jGrGSS jGrGSS jGrGSS jGrGSS jGrGSS jGr        GSS jGrGSS jGrGS S jGrGS!S jGr " S S5      GrGS"S jGr " S S5      Gr      GS#S jGr    GS$S jGrGS%S jGrSS.GS&S jjGr " S S\%\   5      Gr \" SSR9GS'S j5       Gr!GS(S jGr" " S S\\   \\'\   5      Gr# " S S\'\   5      Gr$ " S S5      Gr%GS)S jGr&        GS*S jGr'\GRP                  S:w  a  GS+S jGr)OGS+S jGr)      GS,S jGr* " S S\5      Gr+G\+GRX                  Gr-G\-Gr,G\." S5      Gr/g(-      )annotationsN)Callable
Collection	ContainerIterableIteratorMappingSequence)timezone)Enumauto)cache	lru_cachewraps)	find_spec)getattr_staticgetdoc)
attrgetter)Path)	token_hex)	TYPE_CHECKINGAnyFinalGenericLiteralProtocolTypeVarcastoverload)
NoAutoEnum)issue_deprecation_warning)assert_never
deprecated)get_cudfget_dask_dataframe
get_duckdbget_ibis	get_modin
get_pandas
get_polarsget_pyarrowget_pyspark_connectget_pyspark_sqlget_sqlframeis_narwhals_seriesis_narwhals_series_boolis_narwhals_series_intis_numpy_array_1dis_numpy_array_1d_boolis_numpy_array_1d_intis_pandas_like_dataframeis_pandas_like_series)ColumnNotFoundErrorDuplicateErrorInvalidOperationError
ShapeError)Set)
ModuleType)Concatenate	TypeAlias)LiteralString	ParamSpecSelfTypeIs)CompliantExprTCompliantSeriesTNativeSeriesT_co)NamespaceAccessor)Accessor	EvalNamesNativeDataFrameTNativeLazyFrameT	Namespace)NativeArrow
NativeCuDF
NativeDaskNativeDuckDB
NativeIbisNativeModinNativePandasNativePandasLikeNativePolarsNativePySparkNativePySparkConnectNativeSQLFrame)ArrowStreamExportableIntoArrowTableToNarwhalsT_co)BackendIntoBackend
PluginName
_ArrowImpl	_CuDFImpl	_DaskImpl_DuckDBImpl_EagerAllowedImpl	_IbisImpl_LazyAllowedImpl_LazyFrameCollectImpl
_ModinImpl_PandasImpl_PandasLikeImpl_PolarsImpl_PySparkConnectImpl_PySparkImpl_SQLFrameImpl	DataFrame	LazyFrameDTypeSeries)CompliantDataFrameCompliantLazyFrameCompliantSeriesDTypes
FileSourceIntoSeriesTMultiIndexSelectorNestedLiteralNormalizedPathSingleIndexSelectorSizedMultiBoolSelectorSizedMultiIndexSelectorSizeUnitSupportsNativeNamespaceTimeUnit_1DArray_SliceIndex
_SliceName
_SliceNoneFrameOrSeriesT)bound_T1_T2_T3_FnzCallable[..., Any]PRR1R2c                       \ rS rSr% S\S'   Srg)_SupportsVersion   str__version__ N__name__
__module____qualname____firstlineno____annotations____static_attributes__r       K/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/narwhals/_utils.pyr   r      s    r   r   c                  "    \ rS rSrSSS jjrSrg)_SupportsGet   Nc                   g Nr   selfinstanceowners      r   __get___SupportsGet.__get__   s    cr   r   r   )r   r   r   
Any | Nonereturnr   )r   r   r   r   r   r   r   r   r   r   r      s    QQr   r   c                  (    \ rS rSr\SS j5       rSrg)_StoresColumns   c                    g r   r   r   s    r   columns_StoresColumns.columns   s    ,/r   r   N)r   Sequence[str])r   r   r   r   propertyr   r   r   r   r   r   r      s    	/ 
/r   r   _T
NativeT_coT)	covariantCompliantT_coz._FullContext | NamespaceAccessor[_FullContext]r>   _IntoContext_IntoContextTz*Callable[Concatenate[_IntoContextT, P], R]_Methodz Callable[Concatenate[_T, P], R2]_Constructorc                  ,    \ rS rSrSr\SS j5       rSrg)_StoresNative   zProvides access to a native object.

Native objects have types like:

>>> from pandas import Series
>>> from pyarrow import Table
c                    g)zReturn the native object.Nr   r   s    r   native_StoresNative.native        	r   r   N)r   r   )r   r   r   r   __doc__r   r   r   r   r   r   r   r            r   r   c                  ,    \ rS rSrSr\SS j5       rSrg)_StoresCompliant   zProvides access to a compliant object.

Compliant objects have types like:

>>> from narwhals._pandas_like.series import PandasLikeSeries
>>> from narwhals._arrow.dataframe import ArrowDataFrame
c                    g)zReturn the compliant object.Nr   r   s    r   	compliant_StoresCompliant.compliant   r   r   r   N)r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r      r   r   r   c                  (    \ rS rSr\SS j5       rSrg)_StoresBackendVersion   c                    g)z#Version tuple for a native package.Nr   r   s    r   _backend_version&_StoresBackendVersion._backend_version   r   r   r   Nr   tuple[int, ...])r   r   r   r   r   r   r   r   r   r   r   r      s     r   r   c                       \ rS rSr% S\S'   Srg)_StoresVersion   Version_versionr   Nr   r   r   r   r   r      s    ,r   r   c                       \ rS rSr% S\S'   Srg)_StoresImplementation   Implementation_implementationr   Nr   r   r   r   r   r      s    ##Ir   r   c                      \ rS rSrSrSrg)_LimitedContext   z9Provides 2 attributes.

- `_implementation`
- `_version`
r   Nr   r   r   r   r   r   r   r   r   r   r          r   r   c                      \ rS rSrSrSrg)_FullContext   zAProvides 2 attributes.

- `_implementation`
- `_backend_version`
r   Nr   r   r   r   r   r      r   r   r   c                  "    \ rS rSrSrSS jrSrg)ValidateBackendVersion   z=Ensure the target `Implementation` is on a supported version.c                8    U R                   R                  5       ng)zRaise if installed version below `nw._utils.MIN_VERSIONS`.

**Only use this when moving between backends.**
Otherwise, the validation will have taken place already.
N)r   r   )r   _s     r   _validate_backend_version0ValidateBackendVersion._validate_backend_version   s       113r   r   N)r   None)r   r   r   r   r   r   r   r   r   r   r   r      s
    G4r   r   c                      \ rS rSr\" 5       r\" 5       r\" 5       r\S	S j5       r	\S
S j5       r
\SS j5       r\SS j5       r\SS j5       rSrg)r      c                    [        U 5      $ r   )_version_namespacer   s    r   	namespaceVersion.namespace      !$''r   c                    [        U 5      $ r   )_version_dtypesr   s    r   dtypesVersion.dtypes      t$$r   c                    [        U 5      $ r   )_version_dataframer   s    r   	dataframeVersion.dataframe
  r   r   c                    [        U 5      $ r   )_version_lazyframer   s    r   	lazyframeVersion.lazyframe  r   r   c                    [        U 5      $ r   )_version_seriesr   s    r   seriesVersion.series  r   r   r   N)r   type[Namespace[Any]])r   rx   )r   type[DataFrame[Any]])r   type[LazyFrame[Any]])r   type[Series[Any]])r   r   r   r   r   V1V2MAINr   r   r   r   r  r  r   r   r   r   r   r      sy    	B	B6D( ( % % ( ( ( ( % %r   r      )maxsizec               ~    U [         R                  L a  SSKJn  U$ U [         R                  L a  SSKJn  U$ SSKJn  U$ )Nr   rK   )r   r  narwhals.stable.v1._namespacerL   r  narwhals.stable.v2._namespacenarwhals._namespace)versionNamespaceV1NamespaceV2rL   s       r   r   r     s5    '**J'**J-r   c               ~    U [         R                  L a  SSKJn  U$ U [         R                  L a  SSKJn  U$ SSKJn  U$ )Nr   )r   )r   r  narwhals.stable.v1r   r  narwhals.stable.v2narwhals)r  	dtypes_v1	dtypes_v2r   s       r   r   r   &  s4    '**:'**:Mr   c               ~    U [         R                  L a  SSKJn  U$ U [         R                  L a  SSKJn  U$ SSKJn  U$ )Nr   )ro   )r   r  r  ro   r  r  narwhals.dataframe)r  DataFrameV1DataFrameV2ro   s       r   r   r   5  5    '**?'**?,r   c               ~    U [         R                  L a  SSKJn  U$ U [         R                  L a  SSKJn  U$ SSKJn  U$ )Nr   )rp   )r   r  r  rp   r  r  r  )r  LazyFrameV1LazyFrameV2rp   s       r   r  r  D  r"  r   c               ~    U [         R                  L a  SSKJn  U$ U [         R                  L a  SSKJn  U$ SSKJn  U$ )Nr   rs   )r   r  r  rt   r  r  narwhals.series)r  SeriesV1SeriesV2rt   s       r   r  r  S  s2    '**9'**9&Mr   c                  T   \ rS rSrSrSr Sr Sr Sr Sr	 Sr
 S	r S
r Sr Sr Sr Sr S$S jr\      S%S j5       r\S&S j5       r\      S'S j5       rS(S jrS)S jrS)S jrS)S jrS)S jrS)S jrS)S jrS)S jrS)S jrS)S jrS)S jr S)S jr!S)S jr"S)S  jr#S*S! jr$S"r%g#)+r   ib  z?Implementation of native object (pandas, Polars, PyArrow, ...).pandasmodincudfpyarrowpysparkpolarsdaskduckdbibissqlframezpyspark[connect]unknownc                ,    [        U R                  5      $ r   )r   valuer   s    r   __str__Implementation.__str__~  s    4::r   c                V   [        5       [        R                  [        5       [        R                  [        5       [        R                  [        5       [        R                  [        5       [        R                  [        5       [        R                  [        5       [        R                  [        5       [        R                   [#        5       [        R$                  ['        5       [        R(                  [+        5       [        R,                  0nUR/                  U[        R0                  5      $ )zvInstantiate Implementation object from a native namespace module.

Arguments:
    native_namespace: Native namespace.
)r)   r   PANDASr(   MODINr$   CUDFr+   PYARROWr-   PYSPARKr*   POLARSr%   DASKr&   DUCKDBr'   IBISr.   SQLFRAMEr,   PYSPARK_CONNECTgetUNKNOWN)clsnative_namespacemappings      r   from_native_namespace$Implementation.from_native_namespace  s     L.//K--J++M>11~55L.// ."5"5L.//J++NN33!>#A#A
 {{+^-C-CDDr   c                T     U " U5      $ ! [          a    [        R                  s $ f = f)zInstantiate Implementation object from a native namespace module.

Arguments:
    backend_name: Name of backend, expressed as string.
)
ValueErrorr   rG  )rH  backend_names     r   from_stringImplementation.from_string  s-    	*|$$ 	*!)))	*s   
 ''c                    [        U[        5      (       a  U R                  U5      $ [        U[        5      (       a  U$ U R	                  U5      $ )zInstantiate from native namespace module, string, or Implementation.

Arguments:
    backend: Backend to instantiate Implementation from.
)
isinstancer   rP  r   rK  )rH  backends     r   from_backendImplementation.from_backend  sR     '3'' OOG$	
 '>22 	

 **73	
r   c                    U [         R                  L a  Sn[        U5      eU R                  5         [        R                  X R                  5      n[        U5      $ )zCReturn the native namespace module corresponding to Implementation.z:Cannot return native namespace from UNKNOWN Implementation)r   rG  AssertionErrorr   _IMPLEMENTATION_TO_MODULE_NAMErF  r7  _import_native_namespace)r   msgmodule_names      r   to_native_namespace"Implementation.to_native_namespace  sK    >)))NC %%488zzJ'44r   c                &    U [         R                  L $ )zReturn whether implementation is pandas.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"a": [1, 2, 3]})
    >>> df = nw.from_native(df_native)
    >>> df.implementation.is_pandas()
    True
)r   r;  r   s    r   	is_pandasImplementation.is_pandas       ~,,,,r   c                f    U [         R                  [         R                  [         R                  1;   $ )a  Return whether implementation is pandas, Modin, or cuDF.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"a": [1, 2, 3]})
    >>> df = nw.from_native(df_native)
    >>> df.implementation.is_pandas_like()
    True
)r   r;  r<  r=  r   s    r   is_pandas_likeImplementation.is_pandas_like  s(     --~/C/C^EXEXYYYr   c                f    U [         R                  [         R                  [         R                  1;   $ )a	  Return whether implementation is pyspark or sqlframe.

Examples:
    >>> import pandas as pd
    >>> import narwhals as nw
    >>> df_native = pd.DataFrame({"a": [1, 2, 3]})
    >>> df = nw.from_native(df_native)
    >>> df.implementation.is_spark_like()
    False
)r   r?  rD  rE  r   s    r   is_spark_likeImplementation.is_spark_like  s1     ""##**
 
 	
r   c                &    U [         R                  L $ )zReturn whether implementation is Polars.

Examples:
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
    >>> df = nw.from_native(df_native)
    >>> df.implementation.is_polars()
    True
)r   r@  r   s    r   	is_polarsImplementation.is_polars  rb  r   c                &    U [         R                  L $ )zReturn whether implementation is cuDF.

Examples:
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
    >>> df = nw.from_native(df_native)
    >>> df.implementation.is_cudf()
    False
)r   r=  r   s    r   is_cudfImplementation.is_cudf       ~****r   c                &    U [         R                  L $ )zReturn whether implementation is Modin.

Examples:
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
    >>> df = nw.from_native(df_native)
    >>> df.implementation.is_modin()
    False
)r   r<  r   s    r   is_modinImplementation.is_modin  s     ~++++r   c                &    U [         R                  L $ )zReturn whether implementation is PySpark.

Examples:
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
    >>> df = nw.from_native(df_native)
    >>> df.implementation.is_pyspark()
    False
)r   r?  r   s    r   
is_pysparkImplementation.is_pyspark       ~----r   c                &    U [         R                  L $ )a  Return whether implementation is PySpark.

Examples:
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
    >>> df = nw.from_native(df_native)
    >>> df.implementation.is_pyspark_connect()
    False
)r   rE  r   s    r   is_pyspark_connect!Implementation.is_pyspark_connect  s     ~5555r   c                &    U [         R                  L $ )zReturn whether implementation is PyArrow.

Examples:
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
    >>> df = nw.from_native(df_native)
    >>> df.implementation.is_pyarrow()
    False
)r   r>  r   s    r   
is_pyarrowImplementation.is_pyarrow,  rv  r   c                &    U [         R                  L $ )zReturn whether implementation is Dask.

Examples:
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
    >>> df = nw.from_native(df_native)
    >>> df.implementation.is_dask()
    False
)r   rA  r   s    r   is_daskImplementation.is_dask9  ro  r   c                &    U [         R                  L $ )zReturn whether implementation is DuckDB.

Examples:
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
    >>> df = nw.from_native(df_native)
    >>> df.implementation.is_duckdb()
    False
)r   rB  r   s    r   	is_duckdbImplementation.is_duckdbF  rb  r   c                &    U [         R                  L $ )zReturn whether implementation is Ibis.

Examples:
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
    >>> df = nw.from_native(df_native)
    >>> df.implementation.is_ibis()
    False
)r   rC  r   s    r   is_ibisImplementation.is_ibisS  ro  r   c                &    U [         R                  L $ )zReturn whether implementation is SQLFrame.

Examples:
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
    >>> df = nw.from_native(df_native)
    >>> df.implementation.is_sqlframe()
    False
)r   rD  r   s    r   is_sqlframeImplementation.is_sqlframe`  s     ~....r   c                    [        U 5      $ )zReturns backend version.backend_versionr   s    r   r   Implementation._backend_versionm  r   r   r   Nr   r   )rH  
type[Self]rI  r<   r   r   )rH  r  rO  r   r   r   )rH  r  rT  z!IntoBackend[Backend | PluginName]r   r   )r   r<   )r   boolr   )&r   r   r   r   r   r;  r<  r=  r>  r?  r@  rA  rB  rC  rD  rE  rG  r8  classmethodrK  rP  rU  r]  r`  rd  rg  rj  rm  rq  rt  rx  r{  r~  r  r  r  r   r   r   r   r   r   r   b  s'   IF EDG!G!F DF DH"(O)G! EE+5E	E E. 	* 	* 

"C
	
 
 5-Z
"-+,.6.+-+/%r   r   c                    U R                  5       =(       d    U R                  5       =(       a    U R                  5       S:  $ )zJWhether implementation is PySpark (or PySpark Connect) with version < 4.0.)   r   )rt  rx  r   implementations    r   is_pyspark_pre_4r  r  s9     	!!#J~'H'H'J5

)
)
+f
45r   )   r  r  )r      r   )   
   )   )r     )r      r  )i     )r  r  )   )r  r  r   z(Mapping[Implementation, tuple[int, ...]]MIN_VERSIONSzdask.dataframezmodin.pandaszpyspark.sqlzpyspark.sql.connectzMapping[Implementation, str]rY     c                    SSK Jn  U" U 5      $ )Nr   )import_module)	importlibr  )r\  r  s     r   rZ  rZ    s    '%%r   c                  [        U [        5      (       d  [        U 5        U [        R                  L a  gU n[        R                  XR                  5      n[        U5      nUR                  5       (       a  SS K	nUR                  nOOUR                  5       (       d  UR                  5       (       a  SS KnUnOUR                  5       (       a  SS KnUnOUn[!        U5      nU["        U   =n	:  a  SU SU	 SU 3n
[%        U
5      eU$ )N)r   r   r   r   zMinimum version of z supported by Narwhals is z	, found: )rS  r   r"   rG  rY  rF  r7  rZ  r  sqlframe._versionr   rt  rx  r/  r~  r1  parse_versionr  rN  )r  implr\  rI  r4  into_versionr/  r1  r  min_versionr[  s              r   r  r    s    nn55^$///D044T::FK/< ((			d5577	'L)Gd!33+4#D6)CK=PYZaYbcoNr   c                n    [        [        U 5      S:X  a  [        U S   5      (       a	  U S   5      $ U 5      $ )Nr  r   )listlen_is_iterable)argss    r   flattenr    s1    CIN|DG/D/DQPP4PPr   c                B    [        U [        [        45      (       d  U 4$ U $ r   )rS  r  tuple)args    r   tupleifyr    s    cD%=))vJr   c                   SSK Jn  [        5       =nb&  [        XR                  UR                  45      (       dI  [        5       =nbW  [        XR                  UR                  UR                  UR                  45      (       a  S[        U 5      < S3n[        U5      e[        U [        5      =(       a    [        U [        [        U45      (       + $ )Nr   rs   z(Expected Narwhals class or scalar, got: z`.

Hint: Perhaps you
- forgot a `nw.from_native` somewhere?
- used `pl.col` instead of `nw.col`?)r'  rt   r)   rS  ro   r*   Exprrp   qualified_type_name	TypeErrorr   r   bytes)r  rt   pdplr[  s        r   r  r    s    & |	(Zii=V-W-W|	(sYYr||LMM 77J37O6R S3 3 	 nc8$RZc5&=Q-R)RRr   c                "    [        U [        5      $ r   )rS  r   )vals    r   is_iteratorr    s    c8$$r   c                    [        U [        5      (       a  U OU R                  n[        R                  " SSU5      n[        S UR                  S5       5       5      $ )zSimple version parser; split into a tuple of ints for comparison.

Arguments:
    version: Version string, or object with one, to parse.
z(\D?dev.*$) c              3  d   #    U  H&  n[        [        R                  " S SU5      5      v   M(     g7f)z\Dr  N)intresub).0vs     r   	<genexpr> parse_version.<locals>.<genexpr>  s'     K4JqRVVE2q)**4Js   .0.)rS  r   r   r  r  r  split)r  version_strs     r   r  r    sK     (55'7;N;NK&&[9KKK4E4Ec4JKKKr   c                    g r   r   
obj_or_clscls_or_tuples     r   isinstance_or_issubclassr    s     r   c                    g r   r   r  s     r   r  r          r   c                    g r   r   r  s     r   r  r    s     "r   c                    g r   r   r  s     r   r  r    s     +.r   c                    g r   r   r  s     r   r  r    s     %(r   c                    g r   r   r  s     r   r  r    s     7:r   c                    g r   r   r  s     r   r  r    s     r   c                    SSK Jn  [        X5      (       a  [        X5      $ [        X5      =(       d"    [        U [        5      =(       a    [	        X5      $ )Nr   rq   )narwhals.dtypesrr   rS  type
issubclass)r  r  rr   s      r   r  r    sA    %*$$*33j/ :t$MJ)Mr   c                   ^^ SSK JmJm  [        U4S jU  5       5      (       d  [        U4S jU  5       5      (       a  g SU  Vs/ s H  n[	        U5      PM     sn 3n[        U5      es  snf )Nr   rn   c              3  <   >#    U  H  n[        UT5      v   M     g 7fr   rS  )r  itemro   s     r   r  $validate_laziness.<locals>.<genexpr>!  s     
954:dI&&5   c              3  <   >#    U  H  n[        UT5      v   M     g 7fr   r  )r  r  rp   s     r   r  r  "  s     :EDJtY''Er  zGThe items to concatenate should either all be eager, or all lazy, got: )r  ro   rp   allr  r  )itemsr  r[  ro   rp   s      @@r   validate_lazinessr    sc    7

95
999:E:::SlqTrlqdhUYZ^U_lqTrSs
tC
C. Uss   A*c                :   SSK Jn  SSKJn  SS jn[	        SU 5      n[	        SU5      n[        [        USS5      U5      (       a  [        [        USS5      U5      (       a  U" UR                  R                  R                  5        U" UR                  R                  R                  5        UR                  UR                  R                  UR                  R                  R                  UR                  R                  R                     5      5      $ [        [        USS5      U5      (       a  [        [        USS5      U5      (       a  U" UR                  R                  R                  5        U" UR                  R                  R                  5        UR                  UR                  R                  UR                  R                  R                  UR                  R                  R                     5      5      $ [        [        USS5      U5      (       a  [        [        USS5      U5      (       a  U" UR                  R                  R                  5        U" UR                  R                  R                  5        UR                  UR                  R                  UR                  R                  R                  UR                  R                  R                     5      5      $ [        [        USS5      U5      (       a  [        [        USS5      U5      (       a  U" UR                  R                  R                  5        U" UR                  R                  R                  5        UR                  UR                  R                  UR                  R                  R                  UR                  R                  R                     5      5      $ [        U5      [        U5      :w  a%  S	[        U5       S
[        U5       3n[        U5      eU $ )aP  Align `lhs` to the Index of `rhs`, if they're both pandas-like.

Arguments:
    lhs: Dataframe or Series.
    rhs: Dataframe or Series to align with.

Notes:
    This is only really intended for backwards-compatibility purposes,
    for example if your library already aligns indices for users.
    If you're designing a new library, we highly encourage you to not
    rely on the Index.
    For non-pandas-like inputs, this only checks that `lhs` and `rhs`
    are the same length.

Examples:
    >>> import pandas as pd
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_pd = pd.DataFrame({"a": [1, 2]}, index=[3, 4])
    >>> s_pd = pd.Series([6, 7], index=[4, 3])
    >>> df = nw.from_native(df_pd)
    >>> s = nw.from_native(s_pd, series_only=True)
    >>> nw.to_native(nw.maybe_align_index(df, s))
       a
    4  2
    3  1
r   )PandasLikeDataFrame)PandasLikeSeriesr   c                @    U R                   (       d  Sn[        U5      eg )Nz'given index doesn't have a unique index)	is_uniquerN  )indexr[  s     r   _validate_index*maybe_align_index.<locals>._validate_indexJ  s    ;CS/! r   _compliant_frameN_compliant_seriesz6Expected `lhs` and `rhs` to have the same length, got z and )r  r   r   r   )narwhals._pandas_like.dataframer  narwhals._pandas_like.seriesr  r   rS  getattrr  r   r  _with_compliant_with_nativelocr  r  rN  )lhsrhsr  r  r  lhs_anyrhs_anyr[  s           r   maybe_align_indexr  )  si   < D="
 5#G5#G+T24G 
WW&8$?AT
U
U0077==>0077==>&&$$11((//33G4L4L4S4S4Y4YZ
 	

 +T24G 
WW&94@BR
S
S0077==>1188>>?&&$$11((//33--44::
 	
 ,d35E 
WW&8$?AT
U
U1188>>?0077==>&&%%22))0044,,3399
 	
 ,d35E 
WW&94@BR
S
S1188>>?1188>>?&&%%22))0044--44::
 	
 7|s7|#Fs7|nTYZ]^eZfYghoJr   c                    [        SU 5      nUR                  5       n[        U5      (       d  [        U5      (       a  UR                  $ g)a>  Get the index of a DataFrame or a Series, if it's pandas-like.

Arguments:
    obj: Dataframe or Series.

Notes:
    This is only really intended for backwards-compatibility purposes,
    for example if your library already aligns indices for users.
    If you're designing a new library, we highly encourage you to not
    rely on the Index.
    For non-pandas-like inputs, this returns `None`.

Examples:
    >>> import pandas as pd
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_pd = pd.DataFrame({"a": [1, 2], "b": [4, 5]})
    >>> df = nw.from_native(df_pd)
    >>> nw.maybe_get_index(df)
    RangeIndex(start=0, stop=2, step=1)
    >>> series_pd = pd.Series([1, 2])
    >>> series = nw.from_native(series_pd, series_only=True)
    >>> nw.maybe_get_index(series)
    RangeIndex(start=0, stop=2, step=1)
r   N)r   	to_nativer5   r6   r  )objobj_any
native_objs      r   maybe_get_indexr    sC    4 5#G""$J
++/DZ/P/Pr   )r  c                  SSK Jn  [        SU 5      nUR                  5       nUb  Ub  Sn[        U5      eU(       d  Uc  Sn[        U5      eUb/  [	        U5      (       a  U Vs/ s H	  os" USS9PM     snOU" USS9nOUn[        U5      (       a9  UR                  UR                  R                  UR                  U5      5      5      $ [        U5      (       a`  SSKJ	n	  U(       a  S	n[        U5      eU	" UUU R                  R                  S
9nUR                  UR                  R                  U5      5      $ U$ s  snf )a3  Set the index of a DataFrame or a Series, if it's pandas-like.

Arguments:
    obj: object for which maybe set the index (can be either a Narwhals `DataFrame`
        or `Series`).
    column_names: name or list of names of the columns to set as index.
        For dataframes, only one of `column_names` and `index` can be specified but
        not both. If `column_names` is passed and `df` is a Series, then a
        `ValueError` is raised.
    index: series or list of series to set as index.

Raises:
    ValueError: If one of the following conditions happens

        - none of `column_names` and `index` are provided
        - both `column_names` and `index` are provided
        - `column_names` is provided and `df` is a Series

Notes:
    This is only really intended for backwards-compatibility purposes, for example if
    your library already aligns indices for users.
    If you're designing a new library, we highly encourage you to not
    rely on the Index.

    For non-pandas-like inputs, this is a no-op.

Examples:
    >>> import pandas as pd
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_pd = pd.DataFrame({"a": [1, 2], "b": [4, 5]})
    >>> df = nw.from_native(df_pd)
    >>> nw.to_native(nw.maybe_set_index(df, "b"))  # doctest: +NORMALIZE_WHITESPACE
       a
    b
    4  1
    5  2
r   )r  r   z8Only one of `column_names` or `index` should be providedz3Either `column_names` or `index` should be providedT)pass_through)	set_indexz/Cannot set index using column names on a Seriesr  )narwhals.translater  r   rN  r  r5   r  r  r  r  r6   narwhals._pandas_like.utilsr  r   )
r  column_namesr  r  df_anyr  r[  idxkeysr  s
             r   maybe_set_indexr	    sD   X -%F!!#JE$5HoEMCo E"" ;@@%3Ys.%@5t4 	 
++%%##001E1Ed1KL
 	
 Z((9CCS/!00@@


 %%f&>&>&K&KJ&WXXM1 As   $D<c                   [        SU 5      nUR                  5       n[        U5      (       aY  UR                  5       n[	        X#5      (       a  U$ UR                  UR                  R                  UR                  SS95      5      $ [        U5      (       aY  UR                  5       n[	        X#5      (       a  U$ UR                  UR                  R                  UR                  SS95      5      $ U$ )aw  Reset the index to the default integer index of a DataFrame or a Series, if it's pandas-like.

Arguments:
    obj: Dataframe or Series.

Notes:
    This is only really intended for backwards-compatibility purposes,
    for example if your library already resets the index for users.
    If you're designing a new library, we highly encourage you to not
    rely on the Index.
    For non-pandas-like inputs, this is a no-op.

Examples:
    >>> import pandas as pd
    >>> import polars as pl
    >>> import narwhals as nw
    >>> df_pd = pd.DataFrame({"a": [1, 2], "b": [4, 5]}, index=([6, 7]))
    >>> df = nw.from_native(df_pd)
    >>> nw.to_native(nw.maybe_reset_index(df))
       a  b
    0  1  4
    1  2  5
    >>> series_pd = pd.Series([1, 2])
    >>> series = nw.from_native(series_pd, series_only=True)
    >>> nw.maybe_get_index(series)
    RangeIndex(start=0, stop=2, step=1)
r   T)drop)r   r  r5   __native_namespace___has_default_indexr  r  r  reset_indexr6   r  )r  r  r  rI  s       r   maybe_reset_indexr    s    8 5#G""$J
++"779j;;N&&$$11*2H2Hd2H2ST
 	
 Z(("779j;;N&&%%22:3I3It3I3TU
 	
 Nr   c                ,    [        XR                  5      $ r   )rS  
RangeIndex)r  rI  s     r   _is_range_indexr  +  s    c6677r   c                    U R                   n[        X!5      =(       aD    UR                  S:H  =(       a.    UR                  [	        U5      :H  =(       a    UR
                  S:H  $ )Nr   r  )r  r  startstopr  step)native_frame_or_seriesrI  r  s      r   r  r  /  sT     #((E0 	KK1	JJ#e*$	 JJ!O	r   c           	         U R                   R                  5       (       d  U $ U R                  U R                  R	                  U R                  5       R                  " U0 UD65      5      n[        SU5      $ )a  Convert columns or series to the best possible dtypes using dtypes supporting ``pd.NA``, if df is pandas-like.

Arguments:
    obj: DataFrame or Series.
    *args: Additional arguments which gets passed through.
    **kwargs: Additional arguments which gets passed through.

Notes:
    For non-pandas-like inputs, this is a no-op.
    Also, `args` and `kwargs` just get passed down to the underlying library as-is.

Examples:
    >>> import pandas as pd
    >>> import polars as pl
    >>> import narwhals as nw
    >>> import numpy as np
    >>> df_pd = pd.DataFrame(
    ...     {
    ...         "a": pd.Series([1, 2, 3], dtype=np.dtype("int32")),
    ...         "b": pd.Series([True, False, np.nan], dtype=np.dtype("O")),
    ...     }
    ... )
    >>> df = nw.from_native(df_pd)
    >>> nw.to_native(
    ...     nw.maybe_convert_dtypes(df)
    ... ).dtypes  # doctest: +NORMALIZE_WHITESPACE
    a             Int32
    b           boolean
    dtype: object
r   )r  rd  r  
_compliantr  r  convert_dtypesr   )r  r  kwargsresults       r   maybe_convert_dtypesr  ;  sg    B ,,..
  ##CMMO$B$BD$SF$STF  &))r   c                    US;   a  U $ US;   a  U S-  $ US;   a  U S-  $ US;   a  U S-  $ US;   a  U S	-  $ S
U< 3n[        U5      e)zScale size in bytes to other size units (eg: "kb", "mb", "gb", "tb").

Arguments:
    sz: original size in bytes
    unit: size unit to convert into
>   br  >   kb	kilobytesi   >   mb	megabytesi   >   gb	gigabytesi   @>   tb	terabytesl        z9`unit` must be one of {'b', 'kb', 'mb', 'gb', 'tb'}, got rN  )szunitr[  s      r   scale_bytesr+  d  ss     ~	""Dy""G|""G|""G|Gx
PC
S/r   c                Z   SSK Jn  U R                  R                  R                  nU R                  nSn[        X15      (       a@  [        U R                  UR                  5      (       a  UR                  R                  S   nU$ U R                  UR                  :X  a  SnU$ U R                  UR                  :w  a  SnU$ U R                  5       nU R                  nUR                  5       (       a9  UR                  5       S:  a%  [        SUR                  5      R                   S:H  nU$ UR#                  5       (       a!  [%        UR&                  R(                  5      nU$ UR+                  5       (       a5  SS	KJn  U" UR0                  5      =(       a    UR0                  R(                  nU$ )
a  Return whether indices of categories are semantically meaningful.

This is a convenience function to accessing what would otherwise be
the `is_ordered` property from the DataFrame Interchange Protocol,
see https://data-apis.org/dataframe-protocol/latest/API.html.

- For Polars:
  - Enums are always ordered.
  - Categoricals are ordered if `dtype.ordering == "physical"`.
- For pandas-like APIs:
  - Categoricals are ordered if `dtype.cat.ordered == True`.
- For PyArrow table:
  - Categoricals are ordered if `dtype.type.ordered == True`.

Arguments:
    series: Input Series.

Examples:
    >>> import narwhals as nw
    >>> import pandas as pd
    >>> import polars as pl
    >>> data = ["x", "y"]
    >>>
    >>> s_pd = nw.from_native(
    ...     pd.Series(data, dtype=pd.CategoricalDtype(ordered=True)), series_only=True
    ... )
    >>> nw.is_ordered_categorical(s_pd)
    True
    >>> s_pl = nw.from_native(
    ...     pl.Series(data, dtype=pl.Categorical()), series_only=True
    ... )
    >>> nw.is_ordered_categorical(s_pl)
    False
r   )InterchangeSeriesF
is_orderedT)r      zpl.Categoricalphysical)is_dictionary)narwhals._interchange.seriesr-  r  r   r   rS  dtypeCategoricalr   describe_categoricalr   r  r  rj  r   r   orderingrd  r  catorderedr{  narwhals._arrow.utilsr1  r  )r  r-  r   r   r  r   r  r1  s           r   is_ordered_categoricalr:  y  so   F ?%%..55F((IF)//Jf((5 5 !!66|D& M% 
	$" M! 
++	+ M !!#$$>> 5 5 7' A *FLL9BBjPF M   ""&**,,-F
 M	 __;"6;;/GFKK4G4GFMr   c                .    Sn[        USS9  [        XUS9$ )Nz}Use `generate_temporary_column_name` instead. `generate_unique_token` is deprecated and it will be removed in future versionsz1.13.0r   )n_bytesr   prefix)r!   generate_temporary_column_name)r=  r   r>  r[  s       r   generate_unique_tokenr@    s&    	?  cH5)'SYZZr   c                |    Sn U [        U S-
  5       3=oA;  a  U$ US-  nUS:  a  SU < SU 3n[        U5      eM:  )a  Generates a unique column name that is not present in the given list of columns.

It relies on [python secrets token_hex](https://docs.python.org/3/library/secrets.html#secrets.token_hex)
function to return a string nbytes random bytes.

Arguments:
    n_bytes: The number of bytes to generate for the token.
    columns: The list of columns to check for uniqueness.
    prefix: prefix with which the temporary column name should start with.

Returns:
    A unique token that is not present in the given list of columns.

Raises:
    AssertionError: If a unique token cannot be generated after 100 attempts.

Examples:
    >>> import narwhals as nw
    >>> columns = ["abc", "xyz"]
    >>> nw.generate_temporary_column_name(n_bytes=8, columns=columns) not in columns
    True
    >>> temp_name = nw.generate_temporary_column_name(
    ...     n_bytes=8, columns=columns, prefix="foo"
    ... )
    >>> temp_name not in columns and temp_name.startswith("foo")
    True
r   r  d   zMInternal Error: Narwhals was not able to generate a column name with n_bytes=z and not in )r   rX  )r=  r   r>  countertokenr[  s         r   r?  r?    sk    < G
x	'A+ 6788EHL1S=*L	3  !%% r   c                  U(       d-  [        [        U R                  5      R                  U5      5      $ [        U5      n[	        X0R                  S9=n(       a  UeU$ )N)	available)r  setr   intersectioncheck_columns_exist)framesubsetstrictto_droperrors        r   parse_columns_to_droprO    sM     C&33F;<<6lG#G}}EEuENr   c                ,    SS K nU c  UR                  $ U $ Nr   )string
whitespace)
charactersrR  s     r   parse_str_strip_charsrU    s     * 26B
Br   c                Z    [        U [        5      =(       a    [        U [        5      (       + $ r   )rS  r
   r   )sequences    r   is_sequence_but_not_strrX    s    h)K*Xs2K.KKr   c                L    [        U [        5      =(       a    U [        S 5      :H  $ r   )rS  slicer  s    r   is_slice_noner\    s    c5!8cU4[&88r   c                   [        U 5      =(       a8    [        U 5      S:  =(       a    [        U S   5      =(       d    [        U 5      S:H  =(       d/    [        U 5      =(       d    [	        U 5      =(       d    [        U 5      $ rQ  )rX  r  is_single_index_selectorr4   r1   is_compliant_series_intr[  s    r   is_sized_multi_index_selectorr`    sl    
 $C( Yc(Q,C#;CF#CWSUV	( !%		(
 "#&	( #3'r   c                    [        U 5      =(       d/    [        U 5      =(       d    [        U 5      =(       d    [        U 5      $ r   )rX  r2   r/   is_compliant_seriesr[  s    r   is_sequence_likerc    s:     	 $ 	$S!	$c"	$ s#	r   c                H   [        U [        5      =(       a    [        U R                  [        5      =(       dk    [        U R                  [        5      =(       dJ    [        U R
                  [        [        45      =(       a#    U R                  S L =(       a    U R                  S L $ r   )rS  rZ  r  r  r  r  NoneTyper[  s    r   is_slice_indexrf  $  sr    c5! 399c" 	
chh$	
 sxx#x1 !		T!!D r   c                "    [        U [        5      $ r   )rS  ranger[  s    r   is_rangeri  0  s    c5!!r   c                l    [        [        U [        5      =(       a    [        U [         5      (       + 5      $ r   )r  rS  r  r[  s    r   r^  r^  4  s#    
3$BZT-B)BCCr   c                `    [        U 5      =(       d    [        U 5      =(       d    [        U 5      $ r   )r^  r`  rf  r[  s    r   is_index_selectorrl  8  s+     	!% 	(-	#r   c                    [        U 5      =(       a(    [        U 5      S:  =(       a    [        U S   [        5      =(       d/    [	        U 5      =(       d    [        U 5      =(       d    [        U 5      $ rQ  )rX  r  rS  r  r3   r0   is_compliant_series_boolr[  s    r   is_boolean_selectorro  B  sW     
!	%	U3s8a<+TJs1vt<T 	)!#&	)"3'	) $C(	r   c                r    [        [        U [        5      =(       a    U =(       a    [        U S   U5      5      $ rQ  )r  rS  r  )r  tps     r   
is_list_ofrr  M  s)    
3%H#H*SVR2HIIr   c                &    [        S U  5       5      $ )Nc              3  B   #    U  H  n[        U[        5      v   M     g 7fr   )rr  r  )r  preds     r   r  3predicates_contains_list_of_bool.<locals>.<genexpr>U  s     =*$z$%%*s   any)
predicatess    r    predicates_contains_list_of_boolrz  R  s     =*===r   c                    [        [        U 5      =(       a)    [        [        U 5      S 5      =n=(       a    [	        X!5      5      $ r   )r  rX  nextiterrS  )r  rq  firsts      r   is_sequence_ofr  X  s<    $ 	"49d++U	"u! r   c                8    [        U [        [        [        45      $ r   )rS  r  r  dictr[  s    r   is_nested_literalr  a  s    cD%.//r   c               `    U c  Uc  UnU$ U b  Uc	  U (       + nU$ U c  Ub   U$ Sn[        U5      e)Nz,Cannot pass both `strict` and `pass_through`r(  )rL  r  pass_through_defaultr[  s       r   validate_strict_and_pass_thoughr  e  s_     ~,.+  
	 4!z  
L4  =or   r  F)warn_versionrequiredc                   ^ ^ SUU 4S jjnU$ )a   Decorator to transition from `native_namespace` to `backend` argument.

Arguments:
    warn_version: Emit a deprecation warning from this version.
    required: Raise when both `native_namespace`, `backend` are `None`.

Returns:
    Wrapped function, with `native_namespace` **removed**.
c               :   >^  [        T 5      SU UU4S jj5       nU$ )Nc                   > UR                  SS 5      nUR                  SS 5      nUb  Uc  T(       a  Sn[        UTS9  UnO;Ub  Ub  Sn[        U5      eUc%  Uc"  T(       a  STR                   S3n[        U5      eX!S'   T" U 0 UD6$ )NrT  rI  z`native_namespace` is deprecated, please use `backend` instead.

Note: `native_namespace` will remain available in `narwhals.stable.v1`.
See https://narwhals-dev.github.io/narwhals/backcompat/ for more information.
r<  z0Can't pass both `native_namespace` and `backend`z `backend` must be specified in `z`.)popr!   rN  r   )r  kwdsrT  rI  r[  fnr  r  s        r   wrapper=deprecate_native_namespace.<locals>.decorate.<locals>.wrapper  s    hhy$/G#xx(:DA+j 
 .cLI*!-'2EH o%!)go(8RH o%%Ot$t$$r   )r  P.argsr  P.kwargsr   r   )r   )r  r  r  r  s   ` r   decorate,deprecate_native_namespace.<locals>.decorate  s%    	r	% 	% 
	%* r   )r  Callable[P, R]r   r  r   )r  r  r  s   `` r   deprecate_native_namespacer  w  s     2 Or   c                    [        U [        SS9  [        U[        [        S 5      SS9  U S:  a  Sn[        U5      eUb)  US:  a  Sn[        U5      eX:  a  Sn[	        U5      e X4$ U nX4$ )Nwindow_size
param_namemin_samplesr  z+window_size must be greater or equal than 1z+min_samples must be greater or equal than 1z6`min_samples` must be less or equal than `window_size`)ensure_typer  r  rN  r9   )r  r  r[  s      r   _validate_rolling_argumentsr    s     S];S$t*GQ;o??CS/!$JC',, % ## "##r   c                    U b  Ub  Sn[        U5      eU b  U nOUb  [        X!-  5      nOSnUS:  a  SU 3n[        U5      eXR:  a  U(       d  Sn[        U5      eU$ )a  Resolve the concrete number of rows to draw for `DataFrame.sample`/`Series.sample`.

At most one of `n` or `fraction` may be set; if neither is given a single row is
sampled. `fraction` is interpreted relative to `height` and truncated towards zero.

Raises:
    ValueError: If both `n` and `fraction` are specified.
    InvalidOperationError: If the resolved size is negative.
    ShapeError: If the resolved size exceeds `height` and `with_replacement` is False.
z&cannot specify both `n` and `fraction`r  r   z.sample size must be a positive integer, found zScannot take a larger sample than the total population when `with_replacement=false`)rN  r  r9   r:   )nfractionheightwith_replacementr[  sizes         r   _resolve_sample_sizer    sy     	}-6o}		6$%ax>tfE#C((}-coKr   c           
         [         R                  " 5       R                  nUR                  5       R                  5       n[        S U 5       5      nUS-   U::  a  [        U[        U 5      5      nSSU-   S3nU[        U 5      -
  nUSS	US-  -   U  S	US-  US-  -   -   S
3-  nUSSU-   S
3-  nXT-
  S-  nXT-
  S-  XT-
  S-  -   n	U H$  n
USS	U-   U
 S	X-   [        U
5      -
  -   S
3-  nM&     USSU-   S3-  nU$ S[        U 5      -
  nSS SS	US-  -   U  S	US-  US-  -   -   SS S3	$ ! [         a$    [	        [         R
                  " SS5      5      n GN;f = f)NCOLUMNSP   c              3  8   #    U  H  n[        U5      v   M     g 7fr   )r  )r  lines     r   r   generate_repr.<locals>.<genexpr>  s     >3t99      u   ┌u   ─u   ┐
| z|
-u   └u   ┘'   uu   ───────────────────────────────────────u   ┐
|u/   |
| Use `.to_native` to see native output |
└)
osget_terminal_sizer   OSErrorr  getenv
expandtabs
splitlinesmaxr  )headernative_reprterminal_widthnative_linesmax_native_widthlengthoutputheader_extrastart_extra	end_extrar  diffs               r   generate_reprr    s   7--/77 ))+668L>>>!~-%s6{3uv~&e,F+Ac\Q./0PQ@QT`cdTd@d9e8ffijjAcVn%S))0Q6.148QUV7VV	 D#-.tfSI<X[^_c[d<d5e4ffijjF !C's++FD
l^ 419vhsdai$(.B'C&D E9,c	'  7RYYy"567s   D/ /*EEc              r    [        U 5      R                  U5      =n(       a  [        R                  " X!5      $ g r   )rG  
differencer7   'from_missing_and_available_column_names)rK  rF  missings      r   rI  rI    s9     f+((33w3"JJ
 	
 r   c                2   [        U 5      [        [        U 5      5      :w  ap  SSKJn  U" U 5      nUR	                  5        VVs0 s H  u  p4US:  d  M  X4_M     nnnSR                  S UR	                  5        5       5      nSU 3n[        U5      eg s  snnf )Nr   )Counterr  r  c              3  8   #    U  H  u  pS U SU S3v   M     g7f)z
- 'z' z timesNr   )r  kr  s      r   r  0check_column_names_are_unique.<locals>.<genexpr>  s#     L9KaS1#V,9Kr  z"Expected unique column names, got:)r  rG  collectionsr  r  joinr8   )r   r  rC  r  r  
duplicatesr[  s          r   check_column_names_are_uniquer     s    
7|s3w<((''"'.}}@tq!a%dad
@ggL9I9I9KLL23%8S!! ) As   BBc                    U c  1 SkO"[        U [        5      (       a  U 1O
[        U 5      nUc  S 1OF[        U[        [        45      (       a  [        U5      1OU Vs1 s H  o3b  [        U5      OS iM     snnX$4$ s  snf )N>   smsnsus)rS  r   rG  r   )	time_unit	time_zone
time_unitstz
time_zoness        r   _parse_time_unit_and_time_zoner    s      	  i%% [^   
 i#x11 )n<EFIbc"gT1IF  !! Gs   A;c                    [        XR                  5      =(       aF    U R                  U;   =(       a0    U R                  U;   =(       d    SU;   =(       a    U R                  S L$ )N*)rS  Datetimer  r  )r3  r   r  r  s       r   %dtype_matches_time_unit_and_time_zoner     sU     	5//* 	
__
*	
 OOz) Cz!AeooT&Ar   c                   U R                   $ r   r   )rJ  s    r   get_column_namesr  -  s    ==r   c                T    U R                    Vs/ s H  o"U;  d  M
  UPM     sn$ s  snf r   r  )rJ  namescol_names      r   exclude_column_namesr  1  s#    %*]]L]e6KH]LLLs   	%%c                  ^  SU 4S jjnU$ )Nc                  > T$ r   r   )_framer  s    r   r  $passthrough_column_names.<locals>.fn6  s    r   )r  r   r   r   r   )r  r  s   ` r   passthrough_column_namesr  5  s     Ir   r   	_SENTINELc                .    [        X[        5      [        L$ r   )r   r  )r  attrs     r   _hasattr_staticr  ?  s    #Y/y@@r   c                    [        U S5      $ )N__narwhals_dataframe__r  r[  s    r   is_compliant_dataframer  C  s     3 899r   c                    [        U S5      $ )N__narwhals_lazyframe__r  r[  s    r   is_compliant_lazyframer  N  s     3 899r   c                    [        U S5      $ )N__narwhals_series__r  r[  s    r   rb  rb  T  s     3 566r   c                Z    [        U 5      =(       a    U R                  R                  5       $ r   )rb  r3  
is_integerr[  s    r   r_  r_  Z  !     s#>		(<(<(>>r   c                Z    [        U 5      =(       a    U R                  R                  5       $ r   )rb  r3  
is_booleanr[  s    r   rn  rn  `  r  r   c                @    [        U S5      =(       a    [        U S5      $ )Nr   	_accessorr  r[  s    r   _is_namespace_accessorr  f  s     3,Rk1RRr   c                   U [         R                  [         R                  [         R                  [         R                  [         R
                  1;   $ )z.Return True if `impl` allows eager operations.)r   r=  r<  r;  r@  r>  r  s    r   is_eager_allowedr  p  sA      r   c               f    U [         R                  [         R                  [         R                  1;   $ )z4Return True if `LazyFrame.collect(impl)` is allowed.)r   r;  r@  r>  r  s    r   can_lazyframe_collectr  {  s&    N))>+@+@.BXBXYYYr   c                   U [         R                  [         R                  [         R                  [         R                  [         R
                  [         R                  [         R                  1;   $ )z1Return True if `DataFrame.lazy(impl)` is allowed.)r   rA  rB  rC  r@  r?  rE  rD  r  s    r   is_lazy_allowedr    sS    &&  r   c                    [        U S5      $ )Nr  r  r[  s    r   has_native_namespacer    s    3 677r   c                    [        U S5      $ )N__arrow_c_stream__r  r[  s    r   supports_arrow_c_streamr    s    3 455r   c                F   ^ ^ U U4S jU 5       n[        [        XSS95      $ )a+  Remap join keys to avoid collisions.

If left keys collide with the right keys, append the suffix.
If there's no collision, let the right keys be.

Arguments:
    left_on: Left keys.
    right_on: Right keys.
    suffix: Suffix to append to right keys.

Returns:
    A map of old to new right keys.
c              3  >   >#    U  H  oT;   a  U T 3OUv   M     g 7fr   r   )r  keyleft_onsuffixs     r   r  (_remap_full_join_keys.<locals>.<genexpr>  s&      ?G7N3%x3xs   F)rL  )r  zip)r  right_onr  right_keys_suffixeds   ` ` r   _remap_full_join_keysr    s'     ?G H%@AAr   c                   [        S5      (       aR  UR                  R                  R                  S5      R                  nUR
                  R                  XS9R                  $ S[        U 5      < S3n[        U5      e)zGuards `ArrowDataFrame.from_arrow` w/ safer imports.

Arguments:
    data: Object which implements `__arrow_c_stream__`.
    context: Initialized compliant object.
r.  )contextzB'pyarrow>=14.0.0' is required for `from_arrow` for object of type r  )
r   r   r   rU  r   
_dataframe
from_arrowr   r  ModuleNotFoundError)datar  r  r[  s       r   _into_arrow_tabler    sq     ''44Y?II}}'''9@@@NObcgOhNkkl
mC
c
""r   c                   U $ )az  Visual-only marker for unstable functionality.

Arguments:
    fn: Function to decorate.

Returns:
    Decorated function (unchanged).

Examples:
    >>> @unstable
    ... def a_work_in_progress_feature(*args):
    ...     return args
    >>>
    >>> a_work_in_progress_feature.__name__
    'a_work_in_progress_feature'
    >>> a_work_in_progress_feature(1, 2, 3)
    (1, 2, 3)
r   )r  s    r   unstabler    s	    & Ir   c                8   ^  [        U 4S jS 5       5      (       + $ )a  Determines if a datetime format string is 'naive', i.e., does not include timezone information.

A format is considered naive if it does not contain any of the following

- '%s': Unix timestamp
- '%z': UTC offset
- 'Z' : UTC timezone designator

Arguments:
    format: The datetime format string to check.

Returns:
    bool: True if the format is naive (does not include timezone info), False otherwise.
c              3  ,   >#    U  H	  oT;   v   M     g 7fr   r   )r  xformats     r   r  #_is_naive_format.<locals>.<genexpr>  s     :(91;(9s   )z%sz%zZrw  )r"  s   `r   _is_naive_formatr%    s     :(9::::r   c                  r    \ rS rSrSrSSS jjrSS jrSS jr S     SS jjrSS jr	\
SS	 j5       rS
rg)not_implementedi  a  Mark some functionality as unsupported.

Arguments:
    alias: optional name used instead of the data model hook [`__set_name__`].

Returns:
    An exception-raising [descriptor].

Notes:
    - Attribute/method name *doesn't* need to be declared twice
    - Allows different behavior when looked up on the class vs instance
    - Allows us to use `isinstance(...)` instead of monkeypatching an attribute to the function

Examples:
    >>> class Thing:
    ...     def totally_ready(self) -> str:
    ...         return "I'm ready!"
    ...
    ...     not_ready_yet = not_implemented()
    >>>
    >>> thing = Thing()
    >>> thing.totally_ready()
    "I'm ready!"
    >>> thing.not_ready_yet()
    Traceback (most recent call last):
        ...
    NotImplementedError: 'not_ready_yet' is not implemented for: 'Thing'.
    ...
    >>> isinstance(Thing.not_ready_yet, not_implemented)
    True

[`__set_name__`]: https://docs.python.org/3/reference/datamodel.html#object.__set_name__
[descriptor]: https://docs.python.org/3/howto/descriptor.html
Nc                   Xl         g r   )_alias)r   aliass     r   __init__not_implemented.__init__  s	     #(r   c                f    S[        U 5      R                   SU R                   SU R                   3$ )N<z>: r  )r  r   _name_owner_namer   s    r   __repr__not_implemented.__repr__  s1    4:&&'s4+;+;*<Adjj\JJr   c                Z    UR                   U l        U R                  =(       d    UU l        g r   )r   r/  r)  r0  r   r   names      r   __set_name__not_implemented.__set_name__  s     %++-
r   c                   Uc  U $ [        US[        R                  5      nU[        R                  La  [        U5      nOU R                  n[        U R                  U5        g )Nr   )r  r   rG  reprr/  _raise_not_implemented_errorr0  )r   r   r   r  whos        r   r   not_implemented.__get__  s\      K !+<n>T>TU!7!77~&C""C$TZZ5r   c                $    U R                  S5      $ )Nraise)r   )r   r  r  s      r   __call__not_implemented.__call__&  s     ||G$$r   c               2    U " 5       n[        U5      " U5      $ )zAlt constructor, wraps with `@deprecated`.

Arguments:
    message: **Static-only** deprecation message, emitted in an IDE.

[descriptor]: https://docs.python.org/3/howto/descriptor.html
)r#   )rH  messager  s      r   r#   not_implemented.deprecated+  s     e'"3''r   )r)  r0  r/  r   )r*  
str | Noner   r   r  )r   type[_T]r5  r   r   r   )r   z_T | Literal['raise'] | Noner   ztype[_T] | Noner   r   )r  r   r  r   r   r   )rB  r?   r   rA   )r   r   r   r   r   r+  r1  r6  r   r?  r  r#   r   r   r   r   r'  r'    sU    !F(
K. PT4=L	$%
 	( 	(r   r'  c               ,    U < SU< S3n[        U5      e)Nz is not implemented for: z.

If you would like to see this functionality in `narwhals`, please open an issue at: https://github.com/narwhals-dev/narwhals/issues)NotImplementedError)whatr;  r[  s      r   r:  r:  8  s,    (+C7 3S 	S 
 c
""r   c                      \ rS rSr% SrS\S'   S\S'   S\S'    \SSS jj5       r\SS	 j5       r	SS
 jr
SS jrSS jr    SS jrSrg)requiresiA  a  Method decorator for raising under certain constraints.

Attributes:
    _min_version: Minimum backend version.
    _hint: Optional suggested alternative.

Examples:
    >>> class SomeBackend:
    ...     _implementation = Implementation.PYARROW
    ...     _backend_version = 20, 0, 0
    ...
    ...     @requires.backend_version((9000, 0, 0))
    ...     def really_complex_feature(self) -> str:
    ...         return "hello"
    >>> backend = SomeBackend()
    >>> backend.really_complex_feature()
    Traceback (most recent call last):
        ...
    NotImplementedError: `really_complex_feature` is only available in 'pyarrow>=9000.0.0', found version '20.0.0'.
r   _min_versionr   _hint_wrapped_namec               @    U R                  U 5      nXl        X#l        U$ )zMethod decorator for raising below a minimum `_backend_version`.

Arguments:
    minimum: Minimum backend version.
    hint: Optional suggested alternative.
)__new__rK  rL  )rH  minimumhintr  s       r   r  requires.backend_version_  s"     kk#"	
r   c               2    SR                  S U  5       5      $ )Nr  c              3  &   #    U  H  o v   M	     g 7fr   r   )r  ds     r   r  ,requires._unparse_version.<locals>.<genexpr>n  s     81#s   )r  r  s    r   _unparse_versionrequires._unparse_versionl  s    xx8888r   c               R    SU R                   ;  a  U SU R                    3U l         g g Nr  rM  )r   r>  s     r   _qualify_accessor_namerequires._qualify_accessor_namep  s/    d((($*81T-?-?,@!AD )r   c                   [        U5      (       a(  U R                  UR                  5        UR                  nOUnUR                  [        UR                  5      4$ r   )r  r\  r  r   r   r   r   )r   r   r   s      r   _unwrap_contextrequires._unwrap_contextu  sM    !(++''(:(:; **I I))3y/H/H+IIIr   c          	     .   U R                  U5      u  p#X R                  :  a  g U R                  U R                  5      nU R                  U5      nSU R                   SU SU SU< S3	nU R                  (       a  U SU R                   3n[        U5      e)N`z` is only available in 'z>=z', found version r  
)r_  rK  rW  rM  rL  rG  )r   r   r  rT  rP  foundr[  s          r   _ensure_versionrequires._ensure_version}  s    //9'''''(9(9:%%g.$$$%%=gYb	Qbchbkklm::EDJJ<(C!#&&r   c               Z   ^ ^ TR                   T l        [        T5      SUU 4S jj5       nU$ )Nc                >   > TR                  U 5        T" U /UQ70 UD6$ r   )re  )r   r  r  r  r   s      r   r  "requires.__call__.<locals>.wrapper  s&      *h....r   )r   r   r  r  r  r  r   r   )r   rM  r   )r   r  r  s   `` r   r?  requires.__call__  s.      [[	r	/ 
	/
 r   r[  N)r  )rQ  r   rP  r   r   rA   )r  r   r   r   )r>  rG   r   r   )r   r   r   ztuple[tuple[int, ...], str])r   r   r   r   )r  _Method[_IntoContextT, P, R]r   rk  )r   r   r   r   r   r   r  r  staticmethodrW  r\  r_  re  r?  r   r   r   r   rJ  rJ  A  sm    * "!J
 
 
 9 9B
J	'.	%r   rJ  c                    U R                   b  UR                  U R                   5      OS nU R                  b  UR                  U R                  5      S-   OS nU R                  nX#U4$ )Nr  )r  r  r  r  )	str_slicer   r  r  r  s        r   convert_str_slice_to_int_slicero    sX     /8oo.IGMM)//*tE090J7==(1,PTD>>Dr   c                  ^  SU 4S jjnU$ )zSteal the class-level docstring from parent and attach to child `__init__`.

Returns:
    Decorated constructor.

Notes:
    - Passes static typing (mostly)
    - Passes at runtime
c                  > U R                   S:X  a0  [        [        T5      [        5      (       a  [        T5      U l        U $ S[
        R                    SU R                  < ST< 3n[        U5      e)Nr+  z`@zL` is only allowed to decorate an `__init__` with a class-level doc.
Method: z	
Parent: )r   r  r  r   r   inherit_docr   r  )
init_childr[  	tp_parents     r   r  inherit_doc.<locals>.decorate  ss    *,DOT1R1R!'	!2J%%& '!..1 2 m% 	
 nr   )rs  _Constructor[_T, P, R2]r   rv  r   )rt  r  s   ` r   rr  rr    s    	 Or   c                   [        U [        5      (       a  U O
[        U 5      nUR                  S:w  a  UR                  OSnU SUR                   3R	                  S5      $ )Nbuiltinsr  r  )rS  r  r   r   lstrip)r  rq  modules      r   r  r    sO    3%%49B mmz9R]]rFXQr{{m$++C00r   r  c              R   [        X5      (       d  SR                  S U 5       5      nSU< S[        U 5      < 3nU(       aZ  Sn[        U 5      n[	        U5      S:  a  [        U 5       S3nU U S3nS	[	        U5      -  S
[	        U5      -  -   nU SU U SU 3n[        U5      eg)a2  Validate that an object is an instance of one or more specified types.

Parameters:
    obj: The object to validate.
    *valid_types: One or more valid types that `obj` is expected to match.
    param_name: The name of the parameter being validated.
        Used to improve error message clarity.

Raises:
    TypeError: If `obj` is not an instance of any of the provided `valid_types`.

Examples:
    >>> ensure_type(42, int, float)
    >>> ensure_type("hello", str)

    >>> ensure_type("hello", int, param_name="test")
    Traceback (most recent call last):
        ...
    TypeError: Expected 'int', got: 'str'
        test='hello'
             ^^^^^^^
    >>> import polars as pl
    >>> import pandas as pd
    >>> df = pl.DataFrame([[1], [2], [3], [4], [5]], schema=[*"abcde"])
    >>> ensure_type(df, pd.DataFrame, param_name="df")
    Traceback (most recent call last):
        ...
    TypeError: Expected 'pandas.DataFrame', got: 'polars.dataframe.frame.DataFrame'
        df=polars.dataframe.frame.DataFrame(...)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
z | c              3  8   #    U  H  n[        U5      v   M     g 7fr   )r  )r  rq  s     r   r  ensure_type.<locals>.<genexpr>  s     L"1"55r  z	Expected z, got: z    (   z(...)=r  ^rc  N)rS  r  r  r9  r  r  )	r  r  valid_typestp_namesr[  left_padr  assign	underlines	            r   r  r    s    @ c''::LLL(W-@-E,HIHs)C3x"},S12%8 z*Q/Fs6{*sSX~>IEF8C59+6Cn (r   c                  6    \ rS rSrSrSS jrS	S jrS
S jrSrg)_DeferredIterablei  zLStore a callable producing an iterable to defer collection until we need it.c                   Xl         g r   
_into_iter)r   	into_iters     r   r+  _DeferredIterable.__init__  s    6?r   c              #  @   #    U R                  5        S h  vN   g  N7fr   r  r   s    r   __iter___DeferredIterable.__iter__  s     ??$$$s   c                f    U R                  5       n[        U[        5      (       a  U$ [        U5      $ r   )r  rS  r  )r   its     r   to_tuple_DeferredIterable.to_tuple  s)    __E**r9b	9r   r  N)r  zCallable[[], Iterable[_T]]r   r   )r   zIterator[_T])r   ztuple[_T, ...])	r   r   r   r   r   r+  r  r  r   r   r   r   r  r    s    V@%:r   r  @   c                T    U(       a  SR                  U /UQ75      OU n[        U5      $ rZ  )r  r   )r  nestedr5  s      r   deep_attrgetterr    s%    (.388TOFO$DDdr   c                &    [        U/UQ76 " U 5      $ )z+Perform a nested attribute lookup on `obj`.)r  )r  name_1r  s      r   deep_getattrr    s    6+F+C00r   c                      \ rS rSrSrg)	Complianti  r   N)r   r   r   r   r   r   r   r   r  r    s    r   r  c                  ,    \ rS rSrSr\SS j5       rSrg)Narwhalsi  ap  Minimal *Narwhals-level* protocol.

Provides access to a compliant object:

    obj: Narwhals[NativeT_co]]
    compliant: Compliant[NativeT_co] = obj._compliant

Which itself exposes:

    implementation: Implementation = compliant.implementation
    native: NativeT_co = compliant.native

This interface is used for revealing which `Implementation` member is associated with **either**:
- One or more [nominal] native type(s)
- One or more [structural] type(s)
  - where the true native type(s) are [assignable to] *at least* one of them

These relationships are defined in the `@overload`s of `_Implementation.__get__(...)`.

[nominal]: https://typing.python.org/en/latest/spec/glossary.html#term-nominal
[structural]: https://typing.python.org/en/latest/spec/glossary.html#term-structural
[assignable to]: https://typing.python.org/en/latest/spec/glossary.html#term-assignable
c                    g r   r   r   s    r   r  Narwhals._compliant&  s    36r   r   N)r   zCompliant[NativeT_co])r   r   r   r   r   r   r  r   r   r   r   r  r    s    0 6 6r   r  c                     \ rS rSrSrSS jr\SS j5       r\SS j5       r\SS j5       r\SS j5       r\      SS j5       r\SS	 j5       r\      SS
 j5       r\SS j5       r\      SS j5       r\S S j5       r\S!S j5       r\      S"S j5       r\S#S j5       r\      S$S j5       r\S%S j5       rS&S jrSrg)'_Implementationi*  zDescriptor for matching an opaque `Implementation` on a generic class.

Based on [pyright comment](https://github.com/microsoft/pyright/issues/3071#issuecomment-1043978070)
c                    X l         g r   r   r4  s      r   r6  _Implementation.__set_name__0  s    !r   c                    g r   r   r   s      r   r   _Implementation.__get__3      TWr   c                    g r   r   r   s      r   r   r  5  r  r   c                    g r   r   r   s      r   r   r  7      RUr   c                    g r   r   r   s      r   r   r  9      PSr   c                    g r   r   r   s      r   r   r  ;  s     r   c                    g r   r   r   s      r   r   r  ?  r  r   c                    g r   r   r   s      r   r   r  A  s     25r   c                    g r   r   r   s      r   r   r  E  r  r   c                    g r   r   r   s      r   r   r  G  s     r   c                    g r   r   r   s      r   r   r  K  r  r   c                    g r   r   r   s      r   r   r  M  r  r   c                    g r   r   r   s      r   r   r  O  s     .1r   c                    g r   r   r   s      r   r   r  T  s    KNr   c                    g r   r   r   s      r   r   r  V  r  r   c                    g r   r   r   s      r   r   r  Z  s    QTr   c                8    Uc  U $ UR                   R                  $ r   )r  r   r   s      r   r   r  \  s    'tPX-@-@-P-PPr   r  N)r   	type[Any]r5  r   r   r   )r   zNarwhals[NativePolars]r   r   r   rj   )r   zNarwhals[NativePandas]r   r   r   rh   )r   zNarwhals[NativeModin]r   r   r   rg   )r   zNarwhals[NativeCuDF]r   r   r   r`   )r   zNarwhals[NativePandasLike]r   r   r   ri   )r   zNarwhals[NativeArrow]r   r   r   r_   )r   z3Narwhals[NativePolars | NativeArrow | NativePandas]r   r   r   z&_PolarsImpl | _PandasImpl | _ArrowImpl)r   zNarwhals[NativeDuckDB]r   r   r   rb   )r   zNarwhals[NativeSQLFrame]r   r   r   rm   )r   zNarwhals[NativeDask]r   r   r   ra   )r   zNarwhals[NativeIbis]r   r   r   rd   )r   z.Narwhals[NativePySpark | NativePySparkConnect]r   r   r   z"_PySparkImpl | _PySparkConnectImpl)r   r   r   ztype[Narwhals[Any]]r   rA   )r   zDataFrame[Any] | Series[Any]r   r   r   rc   )r   zLazyFrame[Any]r   r   r   re   )r   zNarwhals[Any] | Noner   r   r   r   )	r   r   r   r   r   r6  r   r   r   r   r   r   r  r  *  s|   
" W WW WU US S2;>	  U U5K5TW5	/5 5 W W09<	  S SS S1F1OR1	+1 1 N N 4 =@ 	    T TQr   r  c                x    SS K n[        XR                  5      (       a  UR                  R	                  U 5      $ U $ rQ  )r.  rS  RecordBatchReaderTablefrom_batches)tblpas     r   to_pyarrow_tabler  `  s0    #++,,xx$$S))Jr   c          
     l    U H.  nX2;   d  M
  X#   U :w  d  M  SU SU  SU SX#    S3	n[        U5      e   g)zSEnsure `separator` does not conflict with backend-native aliases passed via `kwds`.z`separator` and `z` do not match: `separator`=z and `z`=r  N)r  )	separatornative_separatorsr  native_separatorr[  s        r   validate_separatorsr  h  s^     .#(>)(K#$4#5 6(k0@/ADDZC[[\^  C.  .r   win32c               x    SSK Jn  U" [        U [        5      (       a  U 5      $ [        [	        U 5      5      5      $ Nr   )r}   )narwhals.typingr}   rS  r   r   sourcer}   s     r   normalize_pathr  w  s-    2
63(?(?fWWSfEVWWr   c               L    SSK Jn  U" [        U 5      R                  5       5      $ r  )r  r}   r   as_posixr  s     r   r  r    s    2d6l33566r   c                N    [        U [        5      (       a  U 4U-  $ [        U 5      $ )zEnsure the given bool or sequence of bools is the correct length.

Stolen from https://github.com/pola-rs/polars/blob/b8bfb07a4a37a8d449d6d1841e345817431142df/py-polars/polars/_utils/various.py#L580-L594
)rS  r  r  )r7  n_matchs     r   extend_boolr    s&     ",E4!8!8E8gJeElJr   c                  "    \ rS rSrSrSS jrSrg)
_NoDefaulti  
NO_DEFAULTc                    g)Nz<no_default>r   r   s    r   r1  _NoDefault.__repr__  s    r   r   Nr  )r   r   r   r   
no_defaultr1  r   r   r   r   r  r    s     Jr   r  )r  r   r   r  )r  r   r   rx   )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   z	list[Any])r  r   r   r   )r  zAny | Iterable[Any]r   r  )r  zIterable[_T] | Anyr   zTypeIs[Iterator[_T]])r  z#str | ModuleType | _SupportsVersionr   r   )r  r  r  rE  r   zTypeIs[type[_T]])r  object | typer  rE  r   zTypeIs[_T | type[_T]])r  r  r  tuple[type[_T1], type[_T2]]r   zTypeIs[type[_T1 | _T2]])r  r  r  r  r   z#TypeIs[_T1 | _T2 | type[_T1 | _T2]])r  r  r  &tuple[type[_T1], type[_T2], type[_T3]]r   zTypeIs[type[_T1 | _T2 | _T3]])r  r  r  r  r   z/TypeIs[_T1 | _T2 | _T3 | type[_T1 | _T2 | _T3]])r  r   r  ztuple[type, ...]r   zTypeIs[Any])r  r   r  r   r   r  )r  zIterable[Any]r   r   )r  r   r  z-Series[Any] | DataFrame[Any] | LazyFrame[Any]r   r   )r  z-DataFrame[Any] | LazyFrame[Any] | Series[Any]r   r   r   )r  r   r  zstr | list[str] | Noner  z6Series[IntoSeriesT] | list[Series[IntoSeriesT]] | Noner   r   )r  r   r   r   )r  r   rI  r   r   zTypeIs[pd.RangeIndex])r  zpd.Series[Any] | pd.DataFramerI  r   r   r  )r  r   r  r  r  z
bool | strr   r   )r)  r  r*  r   r   zint | float)r  zSeries[Any]r   r  )nw)r=  r  r   Container[str]r>  r   r   r   )rJ  r   rK  zIterable[str]rL  r  r   z	list[str])rT  rD  r   r   )rW  Sequence[_T] | Anyr   TypeIs[Sequence[_T]])r  r   r   zTypeIs[_SliceNone])r  r   r   zCTypeIs[SizedMultiIndexSelector[Series[Any] | CompliantSeries[Any]]])r  r  r   z-TypeIs[Sequence[_T] | Series[Any] | _1DArray])r  r   r   zTypeIs[_SliceIndex])r  r   r   zTypeIs[range])r  r   r   zTypeIs[SingleIndexSelector])r  r   r   zTTypeIs[SingleIndexSelector | MultiIndexSelector[Series[Any] | CompliantSeries[Any]]])r  r   r   zBTypeIs[SizedMultiBoolSelector[Series[Any] | CompliantSeries[Any]]])r  r   rq  rE  r   zTypeIs[list[_T]])ry  zCollection[Any]r   zTypeIs[Collection[list[bool]]])r  r   rq  rE  r   r  )r  r   r   zTypeIs[NestedLiteral])rL  bool | Noner  r  r  r  r   r  )r  r   r  r  r   z*Callable[[Callable[P, R]], Callable[P, R]])r  r  r  
int | Noner   ztuple[int, int])
r  r  r  zfloat | Noner  r  r  r  r   r  )r  r   r  r   r   r   )rK  Collection[str]rF  r  r   zColumnNotFoundError | None)r   r  r   r   )r  z$TimeUnit | Iterable[TimeUnit] | Noner  z7str | timezone | Iterable[str | timezone | None] | Noner   z%tuple[Set[TimeUnit], Set[str | None]])
r3  rr   r   rx   r  zSet[TimeUnit]r  zSet[str | None]r   r  )rJ  r   r   r   )rJ  r   r  r  r   r   )r  r   r   zEvalNames[Any])r  r   r  r   r   r  )r  z\CompliantDataFrame[CompliantSeriesT, CompliantExprT, NativeDataFrameT, ToNarwhalsT_co] | Anyr   z^TypeIs[CompliantDataFrame[CompliantSeriesT, CompliantExprT, NativeDataFrameT, ToNarwhalsT_co]])r  zJCompliantLazyFrame[CompliantExprT, NativeLazyFrameT, ToNarwhalsT_co] | Anyr   zLTypeIs[CompliantLazyFrame[CompliantExprT, NativeLazyFrameT, ToNarwhalsT_co]])r  z'CompliantSeries[NativeSeriesT_co] | Anyr   z)TypeIs[CompliantSeries[NativeSeriesT_co]])r  r   r   z'TypeIs[NamespaceAccessor[_FullContext]])r  r   r   zTypeIs[_EagerAllowedImpl])r  r   r   zTypeIs[_LazyFrameCollectImpl])r  r   r   zTypeIs[_LazyAllowedImpl])r  r   r   zTypeIs[SupportsNativeNamespace])r  r   r   zTypeIs[ArrowStreamExportable])r  r  r  r  r  r   r   zdict[str, str])r  rZ   r  r   r   pa.Table)r  r   r   r   )r"  r   r   r  )rH  r   r;  r   r   rG  )rn  r   r   r   r   z"tuple[int | None, int | None, Any])rt  zCallable[P, R1]r   z<Callable[[_Constructor[_T, P, R2]], _Constructor[_T, P, R2]])r  zobject | type[Any]r   r   )r  r   r  r  r  r   r   r   )r  r   r  r   r   zattrgetter[Any])r  r   r  r   r  r   r   r   )r  zpa.Table | pa.RecordBatchReaderr   r  )r  r   r  ztuple[str, ...]r  zMapping[str, Any]r   r   )r  ry   r   r}   )r7  zbool | Iterable[bool]r  r  r   zSequence[bool](0  
__future__r   r  r  syscollections.abcr   r   r   r   r   r	   r
   datetimer   enumr   r   	functoolsr   r   r   importlib.utilr   inspectr   r   operatorr   pathlibr   secretsr   typingr   r   r   r   r   r   r   r   r   narwhals._enumr    narwhals._exceptionsr!   narwhals._typing_compatr"   r#   narwhals.dependenciesr$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   narwhals.exceptionsr7   r8   r9   r:   r;   typesr<   r=   r>   r+  r  r0  r  r.  r  typing_extensionsr?   r@   rA   rB   narwhals._compliantrC   rD   rE   !narwhals._compliant.any_namespacerF   narwhals._compliant.typingrG   rH   rI   rJ   r  rL   narwhals._nativerM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   narwhals._translaterY   rZ   r[   narwhals._typingr\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   r  ro   rp   r  rr   r'  rt   r  ru   rv   rw   rx   ry   rz   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   r   r   r   r   r   r   r   r  r  r   r  r;  r<  r=  r>  r?  rE  r@  rA  rB  rC  rD  r  rY  rZ  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r+  r:  r@  r?  rO  rU  rX  r\  r`  rc  rf  ri  r^  rl  ro  rr  rz  r  r  r  r  r  r  r  rI  r  r  r  r  r  r  objectr  r  r  r  rb  r_  rn  r  r  r  r  r  r  r  r  r  r%  r'  r:  rJ  ro  rr  r  r  r  r  r  r  r  r  r  r  platformr  r  r  r  r  r  re  r   r   r   <module>r     s
   " 	 	 
     - - $ *   
 
 
 & : <     *  # -HHVVC  .    ZY    ( 8%&     , 	#3 ?&+ MN %.C
%.C
%.C
%3
4C#AA	B	B8 Rx R0 0
 T]\T2
48Ji J|<A A<i <HZ( x. H -X -
JH J
+^X (*? 	42H 	4%d %4 1  1  1  1  1 M%Z M%`5 9*EF""F:6Z:6  ).M""$9	@  <  D 2& &  <QS*%L 
$, 

 
  -5   
 
 
""$?"" 
"
 
..-H.(. 
.
 
(($J("( 
(
 
::-S:4: 
:
 
#3 

Y	YKYYxF ,0S EI	S	S(S B	S
 Sl,^8	9	MP			&*	&* $&*0:&*&*R*?F :>[[)[36[[ :>)&)&))&36)&)&X#0@DCL9	H	2	"D	Y	GJ
>>#>0 	
 
& &&)-&/&R$$#-$$0
 ,69MQ@<.=""3"F" +"*

 
.;
IX
	
M 8	5 A:

:
::	S:Q:7	07.7?	0?.??	0?.?SZ

86BB(7BADBB,# ,;$R( R(j#R Rj$1'A61 IK + +\: : 2 
1
*4hz6J
7x
# 7:3Q 3Ql
!
!'6
!>O
!	
! <<7X7K KK K  ""

 :r   