narwhals.Implementation
Bases: Enum
Implementation of native object (pandas, Polars, PyArrow, ...).
CUDF
class-attribute
instance-attribute
CUDF = auto()
cuDF implementation.
DASK
class-attribute
instance-attribute
DASK = auto()
Dask implementation.
DUCKDB
class-attribute
instance-attribute
DUCKDB = auto()
DuckDB implementation.
IBIS
class-attribute
instance-attribute
IBIS = auto()
Ibis implementation.
MODIN
class-attribute
instance-attribute
MODIN = auto()
Modin implementation.
PANDAS
class-attribute
instance-attribute
PANDAS = auto()
Pandas implementation.
POLARS
class-attribute
instance-attribute
POLARS = auto()
Polars implementation.
PYARROW
class-attribute
instance-attribute
PYARROW = auto()
PyArrow implementation.
PYSPARK
class-attribute
instance-attribute
PYSPARK = auto()
PySpark implementation.
PYSPARK_CONNECT
class-attribute
instance-attribute
PYSPARK_CONNECT = auto()
PySpark Connect implementation.
SQLFRAME
class-attribute
instance-attribute
SQLFRAME = auto()
SQLFrame implementation.
UNKNOWN
class-attribute
instance-attribute
UNKNOWN = auto()
Unknown implementation.
from_backend
classmethod
from_backend(
backend: str | Implementation | ModuleType,
) -> Implementation
Instantiate from native namespace module, string, or Implementation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
backend
|
str | Implementation | ModuleType
|
Backend to instantiate Implementation from. |
required |
Returns:
Type | Description |
---|---|
Implementation
|
Implementation. |
from_native_namespace
classmethod
from_native_namespace(
native_namespace: ModuleType,
) -> Implementation
Instantiate Implementation object from a native namespace module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
native_namespace
|
ModuleType
|
Native namespace. |
required |
Returns:
Type | Description |
---|---|
Implementation
|
Implementation. |
from_string
classmethod
from_string(backend_name: str) -> Implementation
Instantiate Implementation object from a native namespace module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
backend_name
|
str
|
Name of backend, expressed as string. |
required |
Returns:
Type | Description |
---|---|
Implementation
|
Implementation. |
is_cudf
is_cudf() -> bool
Return whether implementation is cuDF.
Returns:
Type | Description |
---|---|
bool
|
Boolean. |
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
is_dask
is_dask() -> bool
Return whether implementation is Dask.
Returns:
Type | Description |
---|---|
bool
|
Boolean. |
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
is_duckdb
is_duckdb() -> bool
Return whether implementation is DuckDB.
Returns:
Type | Description |
---|---|
bool
|
Boolean. |
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
is_ibis
is_ibis() -> bool
Return whether implementation is Ibis.
Returns:
Type | Description |
---|---|
bool
|
Boolean. |
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
is_modin
is_modin() -> bool
Return whether implementation is Modin.
Returns:
Type | Description |
---|---|
bool
|
Boolean. |
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
is_pandas
is_pandas() -> bool
Return whether implementation is pandas.
Returns:
Type | Description |
---|---|
bool
|
Boolean. |
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
is_pandas_like
is_pandas_like() -> bool
Return whether implementation is pandas, Modin, or cuDF.
Returns:
Type | Description |
---|---|
bool
|
Boolean. |
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
is_polars
is_polars() -> bool
Return whether implementation is Polars.
Returns:
Type | Description |
---|---|
bool
|
Boolean. |
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
is_pyarrow
is_pyarrow() -> bool
Return whether implementation is PyArrow.
Returns:
Type | Description |
---|---|
bool
|
Boolean. |
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
is_pyspark
is_pyspark() -> bool
Return whether implementation is PySpark.
Returns:
Type | Description |
---|---|
bool
|
Boolean. |
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
is_pyspark_connect
is_pyspark_connect() -> bool
Return whether implementation is PySpark.
Returns:
Type | Description |
---|---|
bool
|
Boolean. |
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
is_spark_like
is_spark_like() -> bool
Return whether implementation is pyspark or sqlframe.
Returns:
Type | Description |
---|---|
bool
|
Boolean. |
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
is_sqlframe
is_sqlframe() -> bool
Return whether implementation is SQLFrame.
Returns:
Type | Description |
---|---|
bool
|
Boolean. |
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
to_native_namespace
to_native_namespace() -> ModuleType
Return the native namespace module corresponding to Implementation.
Returns:
Type | Description |
---|---|
ModuleType
|
Native module. |