Skip to content

Commit

Permalink
docs fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Mar 16, 2024
1 parent b44d749 commit 421494c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
3 changes: 3 additions & 0 deletions demo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ruff: noqa
from typing import Any
import polars as pl
import modin.pandas as mpd

import narwhals as nw

Expand All @@ -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]})
Expand Down
18 changes: 9 additions & 9 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -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!
2 changes: 1 addition & 1 deletion docs/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
4 changes: 4 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ nav:
theme:
name: material
font: false
features:
- content.code.copy
- content.code.annotate
- navigation.footer
plugins:
- search
- mkdocstrings
Expand Down
6 changes: 5 additions & 1 deletion narwhals/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions narwhals/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -31,5 +32,6 @@ def to_native(obj: DataFrame[T] | Series[T]) -> T:
__all__ = [
"get_pandas",
"get_polars",
"get_modin",
"to_native",
]

0 comments on commit 421494c

Please sign in to comment.