o
    Lh                     @  s^  d dl mZ d dlZd dlmZmZ er:d dlZd dlmZ	 d dl
Z
d dlmZ d dlZd dlZd dlZd dlmZ d dlmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z% d7d
dZ&d8ddZ'd9ddZ(d:ddZ)d;ddZ*d<ddZ+d=ddZ,d>d d!Z-d?d#d$Z.d@d&d'Z/dAd)d*Z0dBd,d-Z1dCd/d0Z2dDd2d3Z3dEd4d5Z4g d6Z5dS )F    )annotationsN)TYPE_CHECKINGAny)TypeIs)IMPORT_HOOKSget_cudfget_dask_dataframeget_ibis	get_modin	get_numpy
get_pandas
get_polarsget_pyarrowis_into_dataframeis_into_seriesis_narwhals_dataframeis_narwhals_lazyframeis_narwhals_seriesis_numpy_arrayis_pandas_indexdfr   returnTypeIs[pd.DataFrame]c                   s2   t   }durt |jpt fddtD S )zBCheck whether `df` is a pandas DataFrame without importing pandas.Nc                 3  s4    | ]}t j|d  d uot jjV  qd S N)sysmodulesget
isinstancepandas	DataFrame.0module_namer   mod `/var/www/html/Persson_Maskin/env/lib/python3.10/site-packages/narwhals/stable/v1/dependencies.py	<genexpr>'       
z&is_pandas_dataframe.<locals>.<genexpr>)r   r   r   anyr   )r   pdr%   r#   r&   is_pandas_dataframe%      (r+   serTypeIs[pd.Series[Any]]c                   s2   t   }durt|jpt fddtD S )z@Check whether `ser` is a pandas Series without importing pandas.Nc                 3  s4    | ]}t j|d   d uot jjV  qd S r   )r   r   r   r   r   Seriesr    r$   r-   r%   r&   r'   0   r(   z#is_pandas_series.<locals>.<genexpr>)r   r   r/   r)   r   )r-   r*   r%   r0   r&   is_pandas_series.   r,   r1   TypeIs[mpd.DataFrame]c                 C     t   }duot| |jS )z@Check whether `df` is a modin DataFrame without importing modin.N)r
   r   r   )r   mpdr%   r%   r&   is_modin_dataframe7      r5   TypeIs[mpd.Series]c                 C  r3   )z>Check whether `ser` is a modin Series without importing modin.N)r
   r   r/   )r-   r4   r%   r%   r&   is_modin_series<   r6   r8   TypeIs[cudf.DataFrame]c                 C  r3   )z>Check whether `df` is a cudf DataFrame without importing cudf.N)r   r   r   )r   cudfr%   r%   r&   is_cudf_dataframeA   r6   r;   TypeIs[cudf.Series[Any]]c                 C  r3   )z<Check whether `ser` is a cudf Series without importing cudf.N)r   r   r/   )r-   r:   r%   r%   r&   is_cudf_seriesF   r6   r=   TypeIs[dd.DataFrame]c                 C  r3   )z>Check whether `df` is a Dask DataFrame without importing Dask.N)r   r   r   )r   ddr%   r%   r&   is_dask_dataframeK   r6   r@   TypeIs[ibis.Table]c                 C  s   t   }duot| |jjjS )z:Check whether `df` is a Ibis Table without importing Ibis.N)r	   r   exprtypesTable)r   ibisr%   r%   r&   is_ibis_tableP   s   rF   TypeIs[pl.DataFrame]c                 C  r3   )zBCheck whether `df` is a Polars DataFrame without importing Polars.N)r   r   r   r   plr%   r%   r&   is_polars_dataframeU   r6   rJ   TypeIs[pl.LazyFrame]c                 C  r3   )zBCheck whether `df` is a Polars LazyFrame without importing Polars.N)r   r   	LazyFramerH   r%   r%   r&   is_polars_lazyframeZ   r6   rM   TypeIs[pl.Series]c                 C  r3   )z@Check whether `ser` is a Polars Series without importing Polars.N)r   r   r/   )r-   rI   r%   r%   r&   is_polars_series_   r6   rO   TypeIs[pa.ChunkedArray[Any]]c                 C  r3   )zHCheck whether `ser` is a PyArrow ChunkedArray without importing PyArrow.N)r   r   ChunkedArray)r-   par%   r%   r&   is_pyarrow_chunked_arrayd   r6   rS   TypeIs[pa.Table]c                 C  r3   )z@Check whether `df` is a PyArrow Table without importing PyArrow.N)r   r   rD   )r   rR   r%   r%   r&   is_pyarrow_tablei   r6   rU   boolc                 C     t | pt| pt| S )zCheck whether `df` is a pandas-like DataFrame without doing any imports.

    By "pandas-like", we mean: pandas, Modin, cuDF.
    )r+   r5   r;   )r   r%   r%   r&   is_pandas_like_dataframen      rX   c                 C  rW   )zCheck whether `ser` is a pandas-like Series without doing any imports.

    By "pandas-like", we mean: pandas, Modin, cuDF.
    )r1   r8   r=   )r-   r%   r%   r&   is_pandas_like_seriesv   rY   rZ   )r   r	   r
   r   r   r   r   r;   r=   r@   rF   r   r   r5   r8   r   r   r   r   r+   r   rX   rZ   r1   rJ   rM   rO   rS   rU   )r   r   r   r   )r-   r   r   r.   )r   r   r   r2   )r-   r   r   r7   )r   r   r   r9   )r-   r   r   r<   )r   r   r   r>   )r   r   r   rA   )r   r   r   rG   )r   r   r   rK   )r-   r   r   rN   )r-   r   r   rP   )r   r   r   rT   )r   r   r   rV   )r-   r   r   rV   )6
__future__r   r   typingr   r   r:   dask.dataframe	dataframer?   rE   modin.pandasr   r4   r*   polarsrI   pyarrowrR   typing_extensionsr   narwhals.dependenciesr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r+   r1   r5   r8   r;   r=   r@   rF   rJ   rM   rO   rS   rU   rX   rZ   __all__r%   r%   r%   r&   <module>   s:    H

	
	











