From c25ed02b4079917eb421d2a4e3d0cfb249a95a0b Mon Sep 17 00:00:00 2001 From: Ashley Xu Date: Fri, 26 Jan 2024 23:09:29 +0000 Subject: [PATCH] docs: add code samples for Series.{between, cumprod} --- .../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 1aa4ffffbb..822ac3098e 100644 --- a/third_party/bigframes_vendored/pandas/core/series.py +++ b/third_party/bigframes_vendored/pandas/core/series.py @@ -1774,6 +1774,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. @@ -1796,6 +1832,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. """