From 03dc05b18aeb4fe56b82ba9caa51cc782d9c8475 Mon Sep 17 00:00:00 2001 From: ugohuche Date: Wed, 8 May 2024 20:18:48 +0100 Subject: [PATCH] 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: