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: add code samples for Series.{between, cumprod} #353

Merged
merged 2 commits into from
Jan 30, 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
60 changes: 60 additions & 0 deletions third_party/bigframes_vendored/pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,42 @@ def between(
corresponding Series element is between the boundary values `left` and
`right`. NA values are treated as `False`.

**Examples:**

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

Boundary values are included by default:

>>> s = bpd.Series([2, 0, 4, 8, np.nan])
>>> s.between(1, 4)
0 True
1 False
2 True
3 False
4 <NA>
dtype: boolean

With inclusive set to "neither" boundary values are excluded:

>>> s.between(1, 4, inclusive="neither")
0 True
1 False
2 False
3 False
4 <NA>
dtype: boolean

left and right can be any scalar value:

>>> s = bpd.Series(['Alice', 'Bob', 'Carol', 'Eve'])
>>> s.between('Anna', 'Daniel')
0 False
1 True
2 True
3 False
dtype: boolean

Args:
left (scalar or list-like):
Left boundary.
Expand All @@ -1799,6 +1835,30 @@ def cumprod(self):
Returns a DataFrame or Series of the same size containing the cumulative
product.

**Examples:**

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

>>> s = bpd.Series([2, np.nan, 5, -1, 0])
>>> s
0 2.0
1 <NA>
2 5.0
3 -1.0
4 0.0
dtype: Float64

By default, NA values are ignored.

>>> s.cumprod()
0 2.0
1 <NA>
2 10.0
3 -10.0
4 0.0
dtype: Float64

Returns:
bigframes.series.Series: Return cumulative sum of scalar or Series.
"""
Expand Down