From 09a52fda19cde8efa6b20731d5b8e21f50b18a9a Mon Sep 17 00:00:00 2001 From: Ashley Xu <139821907+ashleyxuu@users.noreply.github.com> Date: Tue, 30 Jan 2024 11:36:15 -0800 Subject: [PATCH] docs: add code samples for `Series.{between, cumprod}` (#353) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 # 🦕 --- .../bigframes_vendored/pandas/core/series.py | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/third_party/bigframes_vendored/pandas/core/series.py b/third_party/bigframes_vendored/pandas/core/series.py index 33f03572f1..9e376c713e 100644 --- a/third_party/bigframes_vendored/pandas/core/series.py +++ b/third_party/bigframes_vendored/pandas/core/series.py @@ -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 + 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 + 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. @@ -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 + 2 5.0 + 3 -1.0 + 4 0.0 + dtype: Float64 + + By default, NA values are ignored. + + >>> s.cumprod() + 0 2.0 + 1 + 2 10.0 + 3 -10.0 + 4 0.0 + dtype: Float64 + Returns: bigframes.series.Series: Return cumulative sum of scalar or Series. """