diff --git a/demo.py b/demo.py index 53c85d972..3ddf7464b 100644 --- a/demo.py +++ b/demo.py @@ -1,6 +1,7 @@ # ruff: noqa from typing import Any import polars as pl +import modin.pandas as mpd import narwhals as nw @@ -23,6 +24,8 @@ def func(df_raw: nw.typing.T) -> nw.typing.T: df = pd.DataFrame({"a": [1, 1, 3], "b": [4, 5, 6], "c": [7, 8, 9]}) print(func(df)) +df = mpd.DataFrame({"a": [1, 1, 3], "b": [4, 5, 6], "c": [7, 8, 9]}) +print(func(df)) df = pl.DataFrame({"a": [1, 1, 3], "b": [4, 5, 6], "c": [7, 8, 9]}) print(func(df)) df = pl.LazyFrame({"a": [1, 1, 3], "b": [4, 5, 6], "c": [7, 8, 9]}) diff --git a/docs/index.md b/docs/index.md index 350173e5e..df96e2c8b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,19 +1,19 @@ # Narwhals -Extremely lightweight compatibility layer between pandas and Polars: +![](assets/image.png) -- ✅ No dependencies. -- ✅ Lightweight: wheel is smaller than 30 kB. -- ✅ Simple, minimal, and predictable. +Extremely lightweight compatibility layer between Polars, pandas, and more. -No need to choose - support both with ease! +Seamlessly support both, without depending on either! + +- ✅ **Just use** a subset of **the Polars API**, no need to learn anything new +- ✅ **No dependencies** (not even Polars), keep your library lightweight +- ✅ Support both **lazy** and eager execution +- ✅ Use Polars **Expressions** ## Who's this for? Anyone wishing to write a library/application/service which consumes dataframes, and wishing to make it completely dataframe-agnostic. -## Let's get started! - -- [Installation](installation.md) -- [Quick start](quick_start.md) +Let's get started! diff --git a/docs/quick_start.md b/docs/quick_start.md index b13192a73..5064b7c4c 100644 --- a/docs/quick_start.md +++ b/docs/quick_start.md @@ -2,7 +2,7 @@ ## Prerequisites -Please start by following the [installation instructions](installation.md) +Please start by following the [installation instructions](installation.md). Then, please install the following: diff --git a/mkdocs.yml b/mkdocs.yml index 7da4de154..064c8fe5b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -12,6 +12,10 @@ nav: theme: name: material font: false + features: + - content.code.copy + - content.code.annotate + - navigation.footer plugins: - search - mkdocstrings diff --git a/narwhals/dataframe.py b/narwhals/dataframe.py index 88edfafb2..524be9986 100644 --- a/narwhals/dataframe.py +++ b/narwhals/dataframe.py @@ -9,6 +9,7 @@ from narwhals.dtypes import to_narwhals_dtype from narwhals.pandas_like.dataframe import PandasDataFrame +from narwhals.translate import get_modin from narwhals.translate import get_pandas from narwhals.translate import get_polars @@ -56,8 +57,11 @@ def __init__( elif (pd := get_pandas()) is not None and isinstance(df, pd.DataFrame): self._dataframe = PandasDataFrame(df, implementation="pandas") self._implementation = "pandas" + elif (mpd := get_modin()) is not None and isinstance(df, mpd.DataFrame): + self._dataframe = PandasDataFrame(df, implementation="modin") + self._implementation = "modin" else: - msg = f"Expected pandas or Polars dataframe or lazyframe, got: {type(df)}" + msg = f"Expected pandas-like dataframe, Polars dataframe, or Polars lazyframe, got: {type(df)}" raise TypeError(msg) _validate_features(self._dataframe, self._features) diff --git a/narwhals/translate.py b/narwhals/translate.py index e7bba9e33..20d028f57 100644 --- a/narwhals/translate.py +++ b/narwhals/translate.py @@ -2,6 +2,7 @@ from typing import TYPE_CHECKING +from narwhals.dependencies import get_modin from narwhals.dependencies import get_pandas from narwhals.dependencies import get_polars @@ -31,5 +32,6 @@ def to_native(obj: DataFrame[T] | Series[T]) -> T: __all__ = [ "get_pandas", "get_polars", + "get_modin", "to_native", ]