Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: code samples for Series.{argmax, argmin, is_monotonic_increasing, is_monotonic_decreasing} #323

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions third_party/bigframes_vendored/pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2711,6 +2711,31 @@ def argmax(self):

If the minimum is achieved in multiple locations, the first row position is returned.

**Examples:**

>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None

Consider dataset containing cereal calories.

>>> s = bpd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0,
... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0})
>>> s
Corn Flakes 100.0
Almond Delight 110.0
Cinnamon Toast Crunch 120.0
Cocoa Puff 110.0
dtype: Float64

>>> s.argmax()
shobsi marked this conversation as resolved.
Show resolved Hide resolved
2

>>> s.argmin()
0

The maximum cereal calories is the third element and the minimum cereal
calories is the first element, since series is zero-indexed.

Returns:
Series: Row position of the maximum value.
"""
Expand All @@ -2722,6 +2747,31 @@ def argmin(self):

If the maximum is achieved in multiple locations, the first row position is returned.

**Examples:**

>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None

Consider dataset containing cereal calories.

>>> s = bpd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0,
... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0})
>>> s
Corn Flakes 100.0
Almond Delight 110.0
Cinnamon Toast Crunch 120.0
Cocoa Puff 110.0
dtype: Float64

>>> s.argmax()
2

>>> s.argmin()
0

The maximum cereal calories is the third element and the minimum cereal
calories is the first element, since series is zero-indexed.

Returns:
Series: Row position of the minimum value.
"""
Expand Down Expand Up @@ -2971,6 +3021,19 @@ def is_monotonic_increasing(self) -> bool:
"""
Return boolean if values in the object are monotonically increasing.

**Examples:**

>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None

>>> s = bpd.Series([1, 2, 2])
>>> s.is_monotonic_increasing
True

>>> s = bpd.Series([3, 2, 1])
>>> s.is_monotonic_increasing
False

Returns:
bool: Boolean.
"""
Expand All @@ -2981,6 +3044,19 @@ def is_monotonic_decreasing(self) -> bool:
"""
Return boolean if values in the object are monotonically decreasing.

**Examples:**

>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None

>>> s = bpd.Series([3, 2, 2, 1])
>>> s.is_monotonic_decreasing
True

>>> s = bpd.Series([1, 2, 3])
>>> s.is_monotonic_decreasing
False

Returns:
bool: Boolean.
"""
Expand Down