From 03dc05b18aeb4fe56b82ba9caa51cc782d9c8475 Mon Sep 17 00:00:00 2001 From: ugohuche Date: Wed, 8 May 2024 20:18:48 +0100 Subject: [PATCH 1/2] Added docstring for Series.max() --- narwhals/series.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/narwhals/series.py b/narwhals/series.py index 7aca64657..a51d6adbe 100644 --- a/narwhals/series.py +++ b/narwhals/series.py @@ -111,6 +111,32 @@ def min(self) -> Any: return self._series.min() def max(self) -> Any: + """ + Get the maximum value in this Series. + + Examples: + >>> import pandas as pd + >>> import polars as pl + >>> import narwhals as nw + >>> s = [1, 2, 3] + >>> s_pd = pd.Series(s) + >>> s_pl = pl.Series(s) + + We define a data-frame agnostic function: + + >>> def func(s_any): + ... s = nw.from_native(s_any, series_only=True) + ... s = s.max() + ... return nw.to_native(s) + + We can then pass either pandas or Polars to `func`: + + >>> func(s_pd) # doctest:+SKIP + 0 3 + dtype: int64 + >>> func(s_pl) # doctest:+SKIP + 3 + """ return self._series.max() def sum(self) -> Any: From 2ba173baeb6d9bdedcd631a6945d4b6e61071296 Mon Sep 17 00:00:00 2001 From: ugohuche Date: Thu, 9 May 2024 00:11:49 +0100 Subject: [PATCH 2/2] Updated docstring for Series.max() --- narwhals/series.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/narwhals/series.py b/narwhals/series.py index a51d6adbe..bb38ec410 100644 --- a/narwhals/series.py +++ b/narwhals/series.py @@ -122,19 +122,17 @@ def max(self) -> Any: >>> s_pd = pd.Series(s) >>> s_pl = pl.Series(s) - We define a data-frame agnostic function: + We define a library agnostic function: >>> def func(s_any): ... s = nw.from_native(s_any, series_only=True) - ... s = s.max() - ... return nw.to_native(s) + ... return s.max() We can then pass either pandas or Polars to `func`: - >>> func(s_pd) # doctest:+SKIP - 0 3 - dtype: int64 - >>> func(s_pl) # doctest:+SKIP + >>> func(s_pd) + 3 + >>> func(s_pl) 3 """ return self._series.max()