Skip to content

Commit

Permalink
Merge pull request #117 from ugohuche/max
Browse files Browse the repository at this point in the history
Added docstring for Series.max()
  • Loading branch information
MarcoGorelli authored May 9, 2024
2 parents 81e8f79 + 2ba173b commit 0fdbb1c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions narwhals/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,30 @@ 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 library agnostic function:
>>> def func(s_any):
... s = nw.from_native(s_any, series_only=True)
... return s.max()
We can then pass either pandas or Polars to `func`:
>>> func(s_pd)
3
>>> func(s_pl)
3
"""
return self._series.max()

def sum(self) -> Any:
Expand Down

0 comments on commit 0fdbb1c

Please sign in to comment.