narwhals.Implementation
Bases: Enum
Implementation of native object (pandas, Polars, PyArrow, ...).
CUDF = auto()
class-attribute
instance-attribute
cuDF implementation.
DASK = auto()
class-attribute
instance-attribute
Dask implementation.
DUCKDB = auto()
class-attribute
instance-attribute
DuckDB implementation.
IBIS = auto()
class-attribute
instance-attribute
Ibis implementation.
MODIN = auto()
class-attribute
instance-attribute
Modin implementation.
PANDAS = auto()
class-attribute
instance-attribute
Pandas implementation.
POLARS = auto()
class-attribute
instance-attribute
Polars implementation.
PYARROW = auto()
class-attribute
instance-attribute
PyArrow implementation.
PYSPARK = auto()
class-attribute
instance-attribute
PySpark implementation.
SQLFRAME = auto()
class-attribute
instance-attribute
SQLFrame implementation.
UNKNOWN = auto()
class-attribute
instance-attribute
Unknown implementation.
from_backend(backend: str | Implementation | ModuleType) -> Implementation
classmethod
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(native_namespace: ModuleType) -> Implementation
classmethod
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(backend_name: str) -> Implementation
classmethod
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() -> 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() -> 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() -> 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() -> 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() -> 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() -> 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() -> 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() -> 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() -> 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() -> 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_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() -> 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() -> ModuleType
Return the native namespace module corresponding to Implementation.
Returns:
Type | Description |
---|---|
ModuleType
|
Native module. |