narwhals.dependencies
get_cudf()
Get cudf module (if already imported - else return None).
get_ibis()
Get ibis module (if already imported - else return None).
get_modin()
Get modin.pandas module (if already imported - else return None).
get_pandas()
Get pandas module (if already imported - else return None).
get_polars()
Get Polars module (if already imported - else return None).
get_pyarrow()
Get pyarrow module (if already imported - else return None).
is_cudf_dataframe(df)
Check whether df
is a cudf DataFrame without importing cudf.
is_cudf_index(index)
Check whether index
is a cudf Index without importing cudf.
is_cudf_series(ser)
Check whether ser
is a cudf Series without importing cudf.
is_dask_dataframe(df)
Check whether df
is a Dask DataFrame without importing Dask.
is_ibis_table(df)
Check whether df
is a Ibis Table without importing Ibis.
is_into_dataframe(native_dataframe)
Check whether native_dataframe
can be converted to a Narwhals DataFrame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
native_dataframe
|
Any
|
The object to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
|
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
is_into_series(native_series)
Check whether native_series
can be converted to a Narwhals Series.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
native_series
|
IntoSeries
|
The object to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
|
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
is_modin_dataframe(df)
Check whether df
is a modin DataFrame without importing modin.
is_modin_index(index)
Check whether index
is a modin Index without importing modin.
is_modin_series(ser)
Check whether ser
is a modin Series without importing modin.
is_numpy_array(arr)
Check whether arr
is a NumPy Array without importing NumPy.
is_pandas_dataframe(df)
Check whether df
is a pandas DataFrame without importing pandas.
is_pandas_index(index)
Check whether index
is a pandas Index without importing pandas.
is_pandas_like_dataframe(df)
Check whether df
is a pandas-like DataFrame without doing any imports.
By "pandas-like", we mean: pandas, Modin, cuDF.
is_pandas_like_index(index)
Check whether index
is a pandas-like Index without doing any imports.
By "pandas-like", we mean: pandas, Modin, cuDF.
is_pandas_like_series(ser)
Check whether ser
is a pandas-like Series without doing any imports.
By "pandas-like", we mean: pandas, Modin, cuDF.
is_pandas_series(ser)
Check whether ser
is a pandas Series without importing pandas.
is_polars_dataframe(df)
Check whether df
is a Polars DataFrame without importing Polars.
is_polars_lazyframe(df)
Check whether df
is a Polars LazyFrame without importing Polars.
is_polars_series(ser)
Check whether ser
is a Polars Series without importing Polars.
is_pyarrow_chunked_array(ser)
Check whether ser
is a PyArrow ChunkedArray without importing PyArrow.
is_pyarrow_table(df)
Check whether df
is a PyArrow Table without importing PyArrow.