From d450470d4a66283dafac10557b3ea7cc33e5f03e Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Wed, 27 Nov 2024 11:44:19 +0000 Subject: [PATCH] docs: fixup typing in docstrings --- narwhals/expr.py | 18 ++++++++++++++++++ narwhals/series.py | 5 ++++- narwhals/stable/v1/__init__.py | 18 ++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/narwhals/expr.py b/narwhals/expr.py index 9c0a484a5..2862f938e 100644 --- a/narwhals/expr.py +++ b/narwhals/expr.py @@ -5509,6 +5509,7 @@ def col(*names: str | Iterable[str]) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pl = pl.DataFrame({"a": [1, 2], "b": [3, 4]}) >>> df_pd = pd.DataFrame({"a": [1, 2], "b": [3, 4]}) >>> df_pa = pa.table({"a": [1, 2], "b": [3, 4]}) @@ -5565,6 +5566,7 @@ def nth(*indices: int | Sequence[int]) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> data = {"a": [1, 2], "b": [3, 4]} >>> df_pl = pl.DataFrame(data) >>> df_pd = pd.DataFrame(data) @@ -5617,6 +5619,7 @@ def all_() -> Expr: >>> import pandas as pd >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pd = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) >>> df_pl = pl.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) >>> df_pa = pa.table({"a": [1, 2, 3], "b": [4, 5, 6]}) @@ -5668,6 +5671,7 @@ def len_() -> Expr: >>> import pandas as pd >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pd = pd.DataFrame({"a": [1, 2], "b": [5, 10]}) >>> df_pl = pl.DataFrame({"a": [1, 2], "b": [5, 10]}) >>> df_pa = pa.table({"a": [1, 2], "b": [5, 10]}) @@ -5722,6 +5726,7 @@ def sum(*columns: str) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pl = pl.DataFrame({"a": [1, 2]}) >>> df_pd = pd.DataFrame({"a": [1, 2]}) >>> df_pa = pa.table({"a": [1, 2]}) @@ -5772,6 +5777,7 @@ def mean(*columns: str) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pl = pl.DataFrame({"a": [1, 8, 3]}) >>> df_pd = pd.DataFrame({"a": [1, 8, 3]}) >>> df_pa = pa.table({"a": [1, 8, 3]}) @@ -5823,6 +5829,7 @@ def median(*columns: str) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pd = pd.DataFrame({"a": [4, 5, 2]}) >>> df_pl = pl.DataFrame({"a": [4, 5, 2]}) >>> df_pa = pa.table({"a": [4, 5, 2]}) @@ -5873,6 +5880,7 @@ def min(*columns: str) -> Expr: >>> import pandas as pd >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pd = pd.DataFrame({"a": [1, 2], "b": [5, 10]}) >>> df_pl = pl.DataFrame({"a": [1, 2], "b": [5, 10]}) >>> df_pa = pa.table({"a": [1, 2], "b": [5, 10]}) @@ -5923,6 +5931,7 @@ def max(*columns: str) -> Expr: >>> import pandas as pd >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pd = pd.DataFrame({"a": [1, 2], "b": [5, 10]}) >>> df_pl = pl.DataFrame({"a": [1, 2], "b": [5, 10]}) >>> df_pa = pa.table({"a": [1, 2], "b": [5, 10]}) @@ -5974,6 +5983,7 @@ def sum_horizontal(*exprs: IntoExpr | Iterable[IntoExpr]) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> data = {"a": [1, 2, 3], "b": [5, 10, None]} >>> df_pl = pl.DataFrame(data) >>> df_pd = pd.DataFrame(data) @@ -6034,6 +6044,7 @@ def min_horizontal(*exprs: IntoExpr | Iterable[IntoExpr]) -> Expr: Examples: >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> import pandas as pd >>> import polars as pl >>> import pyarrow as pa @@ -6099,6 +6110,7 @@ def max_horizontal(*exprs: IntoExpr | Iterable[IntoExpr]) -> Expr: Examples: >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> import pandas as pd >>> import polars as pl >>> import pyarrow as pa @@ -6198,6 +6210,7 @@ def when(*predicates: IntoExpr | Iterable[IntoExpr]) -> When: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pl = pl.DataFrame({"a": [1, 2, 3], "b": [5, 10, 15]}) >>> df_pd = pd.DataFrame({"a": [1, 2, 3], "b": [5, 10, 15]}) >>> df_pa = pa.table({"a": [1, 2, 3], "b": [5, 10, 15]}) @@ -6255,6 +6268,7 @@ def all_horizontal(*exprs: IntoExpr | Iterable[IntoExpr]) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> data = { ... "a": [False, False, True, True, False, None], ... "b": [False, True, True, None, None, None], @@ -6330,6 +6344,7 @@ def lit(value: Any, dtype: DType | None = None) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pl = pl.DataFrame({"a": [1, 2]}) >>> df_pd = pd.DataFrame({"a": [1, 2]}) >>> df_pa = pa.table({"a": [1, 2]}) @@ -6392,6 +6407,7 @@ def any_horizontal(*exprs: IntoExpr | Iterable[IntoExpr]) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> data = { ... "a": [False, False, True, True, False, None], ... "b": [False, True, True, None, None, None], @@ -6467,6 +6483,7 @@ def mean_horizontal(*exprs: IntoExpr | Iterable[IntoExpr]) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> data = { ... "a": [1, 8, 3], ... "b": [4, 5, None], @@ -6543,6 +6560,7 @@ def concat_str( Examples: >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> import pandas as pd >>> import polars as pl >>> import pyarrow as pa diff --git a/narwhals/series.py b/narwhals/series.py index 8ffe0b0f4..a562a03c3 100644 --- a/narwhals/series.py +++ b/narwhals/series.py @@ -1079,6 +1079,7 @@ def drop_nulls(self) -> Self: >>> import polars as pl >>> import numpy as np >>> import narwhals as nw + >>> from narwhals.typing import IntoSeriesT >>> s_pd = pd.Series([2, 4, None, 3, 5]) >>> s_pl = pl.Series("a", [2, 4, None, 3, 5]) @@ -1876,6 +1877,7 @@ def to_numpy(self) -> np.ndarray: >>> import pandas as pd >>> import polars as pl >>> import narwhals as nw + >>> import numpy as np >>> from narwhals.typing import IntoSeries >>> s = [1, 2, 3] >>> s_pd = pd.Series(s, name="a") @@ -2509,7 +2511,7 @@ def item(self: Self, index: int | None = None) -> Any: Examples: >>> import narwhals as nw - >>> from narwhals.typing import IntoSeriesT + >>> from narwhals.typing import IntoSeries >>> import pandas as pd >>> import polars as pl @@ -2780,6 +2782,7 @@ def to_arrow(self: Self) -> pa.Array: Examples: >>> import narwhals as nw >>> from narwhals.typing import IntoSeries + >>> import pyarrow as pa >>> import pandas as pd >>> import polars as pl >>> data = [1, 2, 3, 4] diff --git a/narwhals/stable/v1/__init__.py b/narwhals/stable/v1/__init__.py index f57212ee6..d2249d7f9 100644 --- a/narwhals/stable/v1/__init__.py +++ b/narwhals/stable/v1/__init__.py @@ -1849,6 +1849,7 @@ def all() -> Expr: >>> import pandas as pd >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pd = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) >>> df_pl = pl.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) >>> df_pa = pa.table({"a": [1, 2, 3], "b": [4, 5, 6]}) @@ -1902,6 +1903,7 @@ def col(*names: str | Iterable[str]) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pl = pl.DataFrame({"a": [1, 2], "b": [3, 4]}) >>> df_pd = pd.DataFrame({"a": [1, 2], "b": [3, 4]}) >>> df_pa = pa.table({"a": [1, 2], "b": [3, 4]}) @@ -1954,6 +1956,7 @@ def nth(*indices: int | Sequence[int]) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> data = {"a": [1, 2], "b": [3, 4]} >>> df_pl = pl.DataFrame(data) >>> df_pd = pd.DataFrame(data) @@ -2001,6 +2004,7 @@ def len() -> Expr: >>> import pandas as pd >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pd = pd.DataFrame({"a": [1, 2], "b": [5, 10]}) >>> df_pl = pl.DataFrame({"a": [1, 2], "b": [5, 10]}) >>> df_pa = pa.table({"a": [1, 2], "b": [5, 10]}) @@ -2049,6 +2053,7 @@ def lit(value: Any, dtype: DType | None = None) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pl = pl.DataFrame({"a": [1, 2]}) >>> df_pd = pd.DataFrame({"a": [1, 2]}) >>> df_pa = pa.table({"a": [1, 2]}) @@ -2103,6 +2108,7 @@ def min(*columns: str) -> Expr: >>> import pandas as pd >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pd = pd.DataFrame({"a": [1, 2], "b": [5, 10]}) >>> df_pl = pl.DataFrame({"a": [1, 2], "b": [5, 10]}) >>> df_pa = pa.table({"a": [1, 2], "b": [5, 10]}) @@ -2153,6 +2159,7 @@ def max(*columns: str) -> Expr: >>> import pandas as pd >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pd = pd.DataFrame({"a": [1, 2], "b": [5, 10]}) >>> df_pl = pl.DataFrame({"a": [1, 2], "b": [5, 10]}) >>> df_pa = pa.table({"a": [1, 2], "b": [5, 10]}) @@ -2203,6 +2210,7 @@ def mean(*columns: str) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pl = pl.DataFrame({"a": [1, 8, 3]}) >>> df_pd = pd.DataFrame({"a": [1, 8, 3]}) >>> df_pa = pa.table({"a": [1, 8, 3]}) @@ -2254,6 +2262,7 @@ def median(*columns: str) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pd = pd.DataFrame({"a": [4, 5, 2]}) >>> df_pl = pl.DataFrame({"a": [4, 5, 2]}) >>> df_pa = pa.table({"a": [4, 5, 2]}) @@ -2304,6 +2313,7 @@ def sum(*columns: str) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pl = pl.DataFrame({"a": [1, 2]}) >>> df_pd = pd.DataFrame({"a": [1, 2]}) >>> df_pa = pa.table({"a": [1, 2]}) @@ -2355,6 +2365,7 @@ def sum_horizontal(*exprs: IntoExpr | Iterable[IntoExpr]) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> data = {"a": [1, 2, 3], "b": [5, 10, None]} >>> df_pl = pl.DataFrame(data) >>> df_pd = pd.DataFrame(data) @@ -2407,6 +2418,7 @@ def all_horizontal(*exprs: IntoExpr | Iterable[IntoExpr]) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> data = { ... "a": [False, False, True, True, False, None], ... "b": [False, True, True, None, None, None], @@ -2474,6 +2486,7 @@ def any_horizontal(*exprs: IntoExpr | Iterable[IntoExpr]) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> data = { ... "a": [False, False, True, True, False, None], ... "b": [False, True, True, None, None, None], @@ -2542,6 +2555,7 @@ def mean_horizontal(*exprs: IntoExpr | Iterable[IntoExpr]) -> Expr: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> data = { ... "a": [1, 8, 3], ... "b": [4, 5, None], @@ -2602,6 +2616,7 @@ def min_horizontal(*exprs: IntoExpr | Iterable[IntoExpr]) -> Expr: Examples: >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> import pandas as pd >>> import polars as pl >>> import pyarrow as pa @@ -2660,6 +2675,7 @@ def max_horizontal(*exprs: IntoExpr | Iterable[IntoExpr]) -> Expr: Examples: >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> import pandas as pd >>> import polars as pl >>> import pyarrow as pa @@ -2846,6 +2862,7 @@ def concat_str( Examples: >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> import pandas as pd >>> import polars as pl >>> import pyarrow as pa @@ -2946,6 +2963,7 @@ def when(*predicates: IntoExpr | Iterable[IntoExpr]) -> When: >>> import polars as pl >>> import pyarrow as pa >>> import narwhals as nw + >>> from narwhals.typing import IntoFrameT >>> df_pl = pl.DataFrame({"a": [1, 2, 3], "b": [5, 10, 15]}) >>> df_pd = pd.DataFrame({"a": [1, 2, 3], "b": [5, 10, 15]}) >>> df_pa = pa.table({"a": [1, 2, 3], "b": [5, 10, 15]})