Skip to content

Commit

Permalink
docs: fixup typing in docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Nov 27, 2024
1 parent 8ea0f09 commit d450470
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
18 changes: 18 additions & 0 deletions narwhals/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]})
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion narwhals/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
18 changes: 18 additions & 0 deletions narwhals/stable/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]})
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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]})
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]})
Expand Down

0 comments on commit d450470

Please sign in to comment.