
    hNI                    L   S SK Jr  S SKrS SKJrJr  S SKJr  \(       ab  S SKrS SK	J
r  S SKrS SKrS SKJr  S SKrS SKrS SKrS SKJr  S SKJr  S SK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&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.  \/" S/5      r0SCS jr1SCS jr2SCS jr3SCS jr4SCS jr5SCS jr6SCS jr7SCS jr8SCS jr9SCS jr:SCS jr;SCS jr<SCS jr=SCS jr>SCS jr?SCS jr@SDS jrASES jrBSFS jrCSGS jrDSHS  jrESIS! jrFSJS" jrGSKS# jrHSLS$ jrISMS% jrJSNS& jrKSOS' jrLSPS( jrMSQS) jrNSRS* jrOSSS+ jrPSTS, jrQSUS- jrRSVS. jrSSWS/ jrTSXS0 jrUSYS1 jrVSZS2 jrWS[S3 jrXS\S4 jrYS]S5 jrZS^S6 jr[S_S7 jr\S`S8 jr]SaS9 jr^SbS: jr_ScS; jr`SdS< jraSeS= jrb    SfS> jrc    SgS? jrdShS@ jreShSA jrf/ SBQrgg)i    )annotationsN)TYPE_CHECKINGAny)issue_warning	DataFrame)	TypeGuardTypeIs)SQLFrameDataFrame)r   	LazyFrameSeries)	IntoDataFrameTIntoLazyFrameTIntoSeriesT_1DArray_1DArrayInt_2DArray_NDArray_NumpyScalar_ShapeT	fireducksc                 B    [         R                  R                  SS5      $ )z;Get Polars module (if already imported - else return None).polarsNsysmodulesget     hC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\narwhals/dependencies.py
get_polarsr"   .       ;;??8T**r    c                 B    [         R                  R                  SS5      $ )z;Get pandas module (if already imported - else return None).pandasNr   r   r    r!   
get_pandasr&   3   r#   r    c                 b    [         R                  R                  SS5      =n b  U R                  $ g)zAGet modin.pandas module (if already imported - else return None).modinN)r   r   r   r%   )r(   s    r!   	get_modinr)   8   s)    $//<||r    c                 B    [         R                  R                  SS5      $ )z9Get cudf module (if already imported - else return None).cudfNr   r   r    r!   get_cudfr,   ?       ;;??64((r    c                 B    [         R                  R                  SS5      $ )z9Get cupy module (if already imported - else return None).cupyNr   r   r    r!   get_cupyr0   D   r-   r    c                 B    [         R                  R                  SS5      $ )z<Get pyarrow module (if already imported - else return None).pyarrowNr   r   r    r!   get_pyarrowr3   I       ;;??9d++r    c                 B    [         R                  R                  SS5      $ )z:Get numpy module (if already imported - else return None).numpyNr   r   r    r!   	get_numpyr7   N   s    ;;??7D))r    c                 B    [         R                  R                  SS5      $ )z2Get dask (if already imported - else return None).daskNr   r   r    r!   get_daskr:   S   r-   r    c                 B    [         R                  R                  SS5      $ )zCGet dask.dataframe module (if already imported - else return None).zdask.dataframeNr   r   r    r!   get_dask_dataframer<   X   s    ;;??+T22r    c                 B    [         R                  R                  SS5      $ )z;Get duckdb module (if already imported - else return None).duckdbNr   r   r    r!   
get_duckdbr?   ]   r#   r    c                 B    [         R                  R                  SS5      $ )z9Get ibis module (if already imported - else return None).ibisNr   r   r    r!   get_ibisrB   b   r-   r    c                     [        5       =n b  [        U S5      (       a  U R                  $ [        R                  R                  SS5      $ )z>Get dask_expr module (if already imported - else return None).N	dask_expr)r<   hasattrrD   r   r   r   )dds    r!   get_dask_exprrG   g   s;     ""/GB4L4L||;;??;--r    c                 B    [         R                  R                  SS5      $ )z<Get pyspark module (if already imported - else return None).pysparkNr   r   r    r!   get_pysparkrJ   n   r4   r    c                 B    [         R                  R                  SS5      $ )z@Get pyspark.sql module (if already imported - else return None).zpyspark.sqlNr   r   r    r!   get_pyspark_sqlrL   s   s    ;;??=$//r    c                 B    [         R                  R                  SS5      $ )zHGet pyspark.sql.connect module (if already imported - else return None).zpyspark.sql.connectNr   r   r    r!   get_pyspark_connectrN   x   s    ;;??0$77r    c                 B    [         R                  R                  SS5      $ )z=Get sqlframe module (if already imported - else return None).sqlframeNr   r   r    r!   get_sqlframerQ   }   s    ;;??:t,,r    c                    [        U 5      (       d  [        U 5      (       a   S[        U 5       S3n[        U[        5        g g )NYou passed a `z` to `is_pandas_dataframe`.

Hint: Instead of e.g. `is_pandas_dataframe(df)`, did you mean `is_pandas_dataframe(df.to_native())`?)is_narwhals_dataframeis_narwhals_lazyframetyper   UserWarning)dfmsgs     r!   _warn_if_narwhals_df_or_lfrZ      sE    R  $9"$=$=T"XJ 'B B 	
 	c;' %>r    c                d    [        U 5      (       a   S[        U 5       S3n[        U[        5        g g )NrS   zz` to `is_pandas_series`.

Hint: Instead of e.g. `is_pandas_series(ser)`, did you mean `is_pandas_series(ser.to_native())`?)is_narwhals_seriesrV   r   rW   )serrY   s     r!   _warn_if_narwhals_seriesr^      s:    #T#YK (@ @ 	
 	c;' r    c                   ^ ^ [        T 5        [        5       =nSL=(       a    [        T UR                  5      =(       d    [	        U U4S j[
         5       5      $ )zCheck whether `df` is a pandas DataFrame without importing pandas.

Warning:
    This method cannot be called on a Narwhals DataFrame/LazyFrame.
Nc              3     >#    U  HP  n[         R                  R                  US 5      =mS L=(       a     [        TTR                  R
                  5      v   MR     g 7fN)r   r   r   
isinstancer%   r   ).0module_namerX   mods     r!   	<genexpr>&is_pandas_dataframe.<locals>.<genexpr>   sR      V (K T2	24? 	1r3:://0	1'   AA)rZ   r&   rb   r   anyIMPORT_HOOKS)rX   pdre   s   ` @r!   is_pandas_dataframerl      sP     r"<R,MB1M RU V (V S r    c                   ^ ^ [        T 5        [        5       =nSL=(       a    [        T UR                  5      =(       d    [	        UU 4S j[
         5       5      $ )zCheck whether `ser` is a pandas Series without importing pandas.

Warning:
    This method cannot be called on Narwhals Series.
Nc              3     >#    U  HP  n[         R                  R                  US 5      =mS L=(       a     [        TTR                  R
                  5      v   MR     g 7fra   )r   r   r   rb   r%   r   )rc   rd   re   r]   s     r!   rf   #is_pandas_series.<locals>.<genexpr>   sR      T (K T2	24? 	/sCJJ--.	/'rh   )r^   r&   rb   r   ri   rj   )r]   rk   re   s   ` @r!   is_pandas_seriesrp      sP     S!<R,KC1K PS T (T Q r    c                   ^ ^ [        5       =nSL=(       a    [        T UR                  5      =(       d    [        U U4S j[         5       5      $ )zACheck whether `index` is a pandas Index without importing pandas.Nc              3     >#    U  HP  n[         R                  R                  US 5      =mS L=(       a     [        TTR                  R
                  5      v   MR     g 7fra   )r   r   r   rb   r%   Index)rc   rd   indexre   s     r!   rf   "is_pandas_index.<locals>.<genexpr>   sR      U (K T2	24? 	0ucjj../	0'rh   )r&   rb   rs   ri   rj   )rt   rk   re   s   ` @r!   is_pandas_indexrv      sF    <R,LE2881L QT U (U R r    c                l    [        U 5        [        5       =nSL=(       a    [        XR                  5      $ )zCheck whether `df` is a modin DataFrame without importing modin.

Warning:
    This method cannot be called on a Narwhals DataFrame/LazyFrame.
N)rZ   r)   rb   r   )rX   mpds     r!   is_modin_dataframery      s,     r";Ct+M
2}}0MMr    c                l    [        U 5        [        5       =nSL=(       a    [        XR                  5      $ )z~Check whether `ser` is a modin Series without importing modin.

Warning:
    This method cannot be called on Narwhals Series.
N)r^   r)   rb   r   )r]   rx   s     r!   is_modin_seriesr{      s,     S!;Ct+K
3

0KKr    c                V    [        5       =nSL=(       a    [        XR                  5      $ )z?Check whether `index` is a modin Index without importing modin.N)r)   rb   rs   )rt   rx   s     r!   is_modin_indexr}      s"    ;Ct+L
5))0LLr    c                l    [        U 5        [        5       =nSL=(       a    [        XR                  5      $ )zCheck whether `df` is a cudf DataFrame without importing cudf.

Warning:
    This method cannot be called on a Narwhals DataFrame/LazyFrame.
N)rZ   r,   rb   r   )rX   r+   s     r!   is_cudf_dataframer      s,     r"JDt+N
2~~0NNr    c                l    [        U 5        [        5       =nSL=(       a    [        XR                  5      $ )z|Check whether `ser` is a cudf Series without importing cudf.

Warning:
    This method cannot be called on Narwhals Series.
N)r^   r,   rb   r   )r]   r+   s     r!   is_cudf_seriesr      s,     S!JDt+L
30LLr    c                V    [        5       =nSL=(       a    [        XR                  5      $ )z=Check whether `index` is a cudf Index without importing cudf.N)r,   rb   rs   )rt   r+   s     r!   is_cudf_indexr      s)    JDt+ 
zz1 r    c                    [        5       =nS L=(       a+    [        XR                  5      =(       a    U R                  S:H  $ )N   )r0   rb   ndarraysize)objr/   s     r!   is_cupy_scalarr      s7    	D( 	sLL)	HHMr    c                l    [        U 5        [        5       =nSL=(       a    [        XR                  5      $ )zCheck whether `df` is a Dask DataFrame without importing Dask.

Warning:
    This method cannot be called on a Narwhals DataFrame/LazyFrame.
N)rZ   r<   rb   r   )rX   rF   s     r!   is_dask_dataframer      s-     r"$&&Bt3T
2||8TTr    c                l    [        U 5        [        5       =nSL=(       a    [        XR                  5      $ )zCheck whether `df` is a DuckDB Relation without importing DuckDB.

Warning:
    This method cannot be called on Narwhals DataFrame/LazyFrame.
N)rZ   r?   rb   DuckDBPyRelation)rX   r>   s     r!   is_duckdb_relationr     s5     r" l"F4/ J
##5 r    c                    [        U 5        [        5       =nSL=(       a)    [        XR                  R                  R
                  5      $ )zCheck whether `df` is a Ibis Table without importing Ibis.

Warning:
    This method cannot be called on Narwhals DataFrame/LazyFrame.
N)rZ   rB   rb   exprtypesTable)rX   rA   s     r!   is_ibis_tabler     s6     r"JDt+U
2yy?T?T0UUr    c                l    [        U 5        [        5       =nSL=(       a    [        XR                  5      $ )zCheck whether `df` is a Polars DataFrame without importing Polars.

Warning:
    This method cannot be called on a Narwhals DataFrame/LazyFrame.
N)rZ   r"   rb   r   rX   pls     r!   is_polars_dataframer     ,     r",Bt+L
2||0LLr    c                l    [        U 5        [        5       =nSL=(       a    [        XR                  5      $ )zCheck whether `df` is a Polars LazyFrame without importing Polars.

Warning:
    This method cannot be called on Narwhals DataFrame/LazyFrame.
N)rZ   r"   rb   r   r   s     r!   is_polars_lazyframer   !  r   r    c                l    [        U 5        [        5       =nSL=(       a    [        XR                  5      $ )zCheck whether `ser` is a Polars Series without importing Polars.

Warning:
    This method cannot be called on Narwhals Series.
N)r^   r"   rb   r   )r]   r   s     r!   is_polars_seriesr   +  s,     S!,Bt+J
3		0JJr    c                l    [        U 5        [        5       =nSL=(       a    [        XR                  5      $ )zCheck whether `ser` is a PyArrow ChunkedArray without importing PyArrow.

Warning:
    This method cannot be called on Narwhals Series.
N)r^   r3   rb   ChunkedArray)r]   pas     r!   is_pyarrow_chunked_arrayr   5  s,     S!-B,QC1QQr    c                l    [        U 5        [        5       =nSL=(       a    [        XR                  5      $ )zCheck whether `df` is a PyArrow Table without importing PyArrow.

Warning:
    This method cannot be called on Narwhals DataFrame/LazyFrame.
N)rZ   r3   rb   r   )rX   r   s     r!   is_pyarrow_tabler   ?  s,     r"-B,IB1IIr    c                V    [        5       =nS L=(       a    [        XR                  5      $ ra   )r3   rb   Scalar)r   r   s     r!   is_pyarrow_scalarr   I  s"    -B,KC1KKr    c                ~    [        U 5        [        [        5       =nSL=(       a    [        XR                  5      5      $ )zCheck whether `df` is a PySpark DataFrame without importing PySpark.

Warning:
    This method cannot be called on a Narwhals DataFrame/LazyFrame.
N)rZ   boolrL   rb   r   )rX   pyspark_sqls     r!   is_pyspark_dataframer   M  s<     r"')	)$6 	2r001 r    c                t    [        U 5        [        5       b   SSKJn  [        X5      $ g! [         a     gf = f)zCheck whether `df` is a PySpark Connect DataFrame without importing PySpark.

Warning:
    This method cannot be called on a Narwhals DataFrame/LazyFrame.
r   r   F)rZ   rN   pyspark.sql.connect.dataframer   ImportErrorrb   rX   r   s     r!   is_pyspark_connect_dataframer   Z  sA     r"(	? "((  		s   * 
77c                R    [        U 5        [        5       b  SSKJn  [	        X5      $ g)zCheck whether `df` is a SQLFrame DataFrame without importing SQLFrame.

Warning:
    This method cannot be called on a Narwhals DataFrame/LazyFrame.
r   )BaseDataFrameF)rZ   rQ   sqlframe.base.dataframer   rb   )rX   r   s     r!   is_sqlframe_dataframer   j  s%     r"~!9",,r    c                V    [        5       =nSL=(       a    [        XR                  5      $ )z=Check whether `arr` is a NumPy Array without importing NumPy.N)r7   rb   r   arrnps     r!   is_numpy_arrayr   x  s"    +Bd*Jz#zz/JJr    c                D    [        U 5      =(       a    U R                  S:H  $ )z@Check whether `arr` is a 1D NumPy Array without importing NumPy.r   r   ndimr   s    r!   is_numpy_array_1dr   }      #0388q=0r    c                    [        5       =n=(       a8    [        U 5      =(       a&    UR                  U R                  UR                  5      $ ra   )r7   r   
issubdtypedtypeintegerr   s     r!   is_numpy_array_1d_intr     s9    {	 	1c"	1MM#))RZZ0r    c                D    [        U 5      =(       a    U R                  S:H  $ )z@Check whether `arr` is a 2D NumPy Array without importing NumPy.   r   r   s    r!   is_numpy_array_2dr     r   r    c                V    [        5       =nSL=(       a    [        XR                  5      $ )zACheck whether `scalar` is a NumPy Scalar without importing NumPy.N)r7   rb   generic)scalarr   s     r!   is_numpy_scalarr     s$    
 +Bd*Mz&**/MMr    c                v    [        U 5        [        U 5      =(       d    [        U 5      =(       d    [        U 5      $ )zCheck whether `df` is a pandas-like DataFrame without doing any imports.

By "pandas-like", we mean: pandas, Modin, cuDF.

Warning:
    This method cannot be called on a Narwhals DataFrame/LazyFrame.
)rZ   rl   ry   r   )rX   s    r!   is_pandas_like_dataframer     s.     r"r"U&8&<U@QRT@UUr    c                v    [        U 5        [        U 5      =(       d    [        U 5      =(       d    [        U 5      $ )zCheck whether `ser` is a pandas-like Series without doing any imports.

By "pandas-like", we mean: pandas, Modin, cuDF.

Warning:
    This method cannot be called on Narwhals Series.
)r^   rp   r{   r   r]   s    r!   is_pandas_like_seriesr     s+     S!C OOC$8ON3<OOr    c                `    [        U 5      =(       d    [        U 5      =(       d    [        U 5      $ )zyCheck whether `index` is a pandas-like Index without doing any imports.

By "pandas-like", we mean: pandas, Modin, cuDF.
)rv   r}   r   )rt   s    r!   is_pandas_like_indexr     s%     	O."7O=;Or    c                    SSK Jn  [        X5      =(       dB    [        U S5      =(       d/    [	        U 5      =(       d    [        U 5      =(       d    [        U 5      $ )ak  Check whether `native_series` can be converted to a Narwhals Series.

Arguments:
    native_series: The object to check.

Returns:
    `True` if `native_series` can be converted to a Narwhals Series, `False` otherwise.

Examples:
    >>> import pandas as pd
    >>> import polars as pl
    >>> import numpy as np
    >>> import narwhals as nw

    >>> s_pd = pd.Series([1, 2, 3])
    >>> s_pl = pl.Series([1, 2, 3])
    >>> np_arr = np.array([1, 2, 3])

    >>> nw.dependencies.is_into_series(s_pd)
    True
    >>> nw.dependencies.is_into_series(s_pl)
    True
    >>> nw.dependencies.is_into_series(np_arr)
    False
r   r   __narwhals_series__)narwhals.seriesr   rb   rE   r   r   r   )native_seriesr   s     r!   is_into_seriesr     sQ    4 ' 	=) 	0="78	0M*	0 $M2	0 !/r    c                    SSK Jn  [        X5      =(       dB    [        U S5      =(       d/    [	        U 5      =(       d    [        U 5      =(       d    [        U 5      $ )a  Check whether `native_dataframe` can be converted to a Narwhals DataFrame.

Arguments:
    native_dataframe: The object to check.

Returns:
    `True` if `native_dataframe` can be converted to a Narwhals DataFrame, `False` otherwise.

Examples:
    >>> import pandas as pd
    >>> import polars as pl
    >>> import numpy as np
    >>> from narwhals.dependencies import is_into_dataframe

    >>> df_pd = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
    >>> df_pl = pl.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
    >>> np_arr = np.array([[1, 4], [2, 5], [3, 6]])

    >>> is_into_dataframe(df_pd)
    True
    >>> is_into_dataframe(df_pl)
    True
    >>> is_into_dataframe(np_arr)
    False
r   r   __narwhals_dataframe__)narwhals.dataframer   rb   rE   r   r   r   )native_dataframer   s     r!   is_into_dataframer     sV    4 - 	#/ 	6#%=>	6/0	6 ,-	6 $$45r    c                $    SSK Jn  [        X5      $ )zCheck whether `df` is a Narwhals DataFrame.

This is useful if you expect a user to pass in a Narwhals
DataFrame directly, and you want to catch both `narwhals.DataFrame`
and `narwhals.stable.v1.DataFrame`.
r   r   )r   r   rb   r   s     r!   rT   rT          -b$$r    c                $    SSK Jn  [        X5      $ )zCheck whether `lf` is a Narwhals LazyFrame.

This is useful if you expect a user to pass in a Narwhals
LazyFrame directly, and you want to catch both `narwhals.LazyFrame`
and `narwhals.stable.v1.LazyFrame`.
r   )r   )r   r   rb   )lfr   s     r!   rU   rU     r   r    c                $    SSK Jn  [        X5      $ )zCheck whether `ser` is a Narwhals Series.

This is useful if you expect a user to pass in a Narwhals
Series directly, and you want to catch both `narwhals.Series`
and `narwhals.stable.v1.Series`.
r   r   )r   r   rb   )r]   r   s     r!   r\   r\     s     'c""r    c                Z    [        U 5      =(       a    U R                  R                  5       $ ra   )r\   r   
is_integerr   s    r!   is_narwhals_series_intr   +  s    c"=syy';';'==r    )r,   rB   r)   r7   r&   r"   r3   r   r   r   r   r   r   ry   r{   rT   rU   r\   r   rl   rv   r   r   rp   r   r   r   r   r   )returnr   )rX   r   r   None)r]   r   r   r   )rX   r   r   zTypeIs[pd.DataFrame])r]   r   r   zTypeIs[pd.Series[Any]])rt   r   r   zTypeIs[pd.Index[Any]])rX   r   r   zTypeIs[mpd.DataFrame])r]   r   r   zTypeIs[mpd.Series])rt   r   r   zTypeIs[mpd.Index[Any]])rX   r   r   zTypeIs[cudf.DataFrame])r]   r   r   zTypeIs[cudf.Series[Any]])rt   r   r   zTypeIs[cudf.Index])r   r   r   r   )rX   r   r   zTypeIs[dd.DataFrame])rX   r   r   zTypeIs[duckdb.DuckDBPyRelation])rX   r   r   zTypeIs[ibis.Table])rX   r   r   zTypeIs[pl.DataFrame])rX   r   r   zTypeIs[pl.LazyFrame])r]   r   r   zTypeIs[pl.Series])r]   r   r   zTypeIs[pa.ChunkedArray[Any]])rX   r   r   zTypeIs[pa.Table])r   r   r   zTypeIs[pa.Scalar[Any]])rX   r   r   zTypeIs[pyspark_sql.DataFrame])rX   r   r   zTypeIs[PySparkConnectDataFrame])rX   r   r   zTypeIs[SQLFrameDataFrame])r   zAny | _NDArray[_ShapeT]r   zTypeIs[_NDArray[_ShapeT]])r   r   r   zTypeIs[_1DArray])r   r   r   zTypeIs[_1DArrayInt])r   r   r   zTypeIs[_2DArray])r   r   r   zTypeGuard[_NumpyScalar])rX   r   r   r   )r]   r   r   r   )rt   r   r   r   )r   zAny | IntoSeriesTr   zTypeIs[IntoSeriesT])r   zAny | IntoDataFrameTr   zTypeIs[IntoDataFrameT])rX   zDataFrame[IntoDataFrameT] | Anyr   z!TypeIs[DataFrame[IntoDataFrameT]])r   zAny | LazyFrame[IntoLazyFrameT]r   z!TypeIs[LazyFrame[IntoLazyFrameT]])r]   zAny | Series[IntoSeriesT]r   zTypeIs[Series[IntoSeriesT]])h
__future__r   r   typingr   r   narwhals._exceptionsr   r+   dask.dataframe	dataframerF   r>   rA   modin.pandasr%   rx   rk   r   r   r2   r   pyspark.sqlsqlr   r   r   PySparkConnectDataFrametyping_extensionsr	   r
   narwhals._spark_like.dataframer   r   r   r   r   narwhals.typingr   r   r   r   r   r   r   r   r   	frozensetrj   r"   r&   r)   r,   r0   r3   r7   r:   r<   r?   rB   rG   rJ   rL   rN   rQ   rZ   r^   rl   rp   rv   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   rT   rU   r\   r   __all__r   r    r!   <module>r      s   # 
 % .%R3@7&
 
 
  +'+
+
)
)
,
*
)
3
+
)
.,
0
8
-
((NLM
OMU	VMMKRJL
 K
1
1
N	V	P"J"J%'%&%%'%&%	#>r    