Skip to content

Commit

Permalink
docs: add code samples for Series.{between, cumprod} (#353)
Browse files Browse the repository at this point in the history
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [ ] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/python-bigquery-dataframes/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [ ] Ensure the tests and linter pass
- [ ] Code coverage does not decrease (if any source code was changed)
- [x] Appropriate docs were updated (if necessary)
     - [x] `Series.between()`: https://screenshot.googleplex.com/BhHpZsL7S9d3FsG
     - [x] `Series.cumprod()`: https://screenshot.googleplex.com/7o7gDNwJZEWst84

Fixes #<issue_number_goes_here> 🦕
  • Loading branch information
ashleyxuu authored Jan 30, 2024
1 parent 5aad3a1 commit 09a52fd
Showing 1 changed file with 60 additions and 0 deletions.
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

0 comments on commit 09a52fd

Please sign in to comment.