From ed360276a3fdcd884fcabd50c74564b204175109 Mon Sep 17 00:00:00 2001 From: Huan Chen Date: Mon, 20 Nov 2023 23:39:04 +0000 Subject: [PATCH 1/3] docs: code samples for dataframe.any, dataframe.all and dataframe.prod --- .../bigframes_vendored/pandas/core/frame.py | 79 ++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/third_party/bigframes_vendored/pandas/core/frame.py b/third_party/bigframes_vendored/pandas/core/frame.py index 8033c064d7..4598a5321f 100644 --- a/third_party/bigframes_vendored/pandas/core/frame.py +++ b/third_party/bigframes_vendored/pandas/core/frame.py @@ -2584,6 +2584,33 @@ def any(self, *, axis=0, bool_only: bool = False): along a Dataframe axis that is True or equivalent (e.g. non-zero or non-empty). + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame({"A": [True, True], "B": [False, False]}) + >>> df + A B + 0 True False + 1 True False + + [2 rows x 2 columns] + + Checking if each column contains at least one True element(the default). + + >>> df.any() + A True + B False + dtype: boolean + + Checking if each row contains at least one True element. + + >>> df.any(axis=1) + 0 True + 1 True + dtype: boolean + Args: axis ({index (0), columns (1)}): Axis for the function to be applied on. @@ -2604,6 +2631,33 @@ def all(self, axis=0, *, bool_only: bool = False): along a DataFrame axis that is False or equivalent (e.g. zero or empty). + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame({"A": [True, True], "B": [False, False]}) + >>> df + A B + 0 True False + 1 True False + + [2 rows x 2 columns] + + Checking if all values in each column are True(the default). + + >>> df.all() + A True + B False + dtype: boolean + + Checking across rows to see if all values are True. + + >>> df.all(axis=1) + 0 False + 1 False + dtype: boolean + Args: axis ({index (0), columns (1)}): Axis for the function to be applied on. @@ -2620,8 +2674,31 @@ def prod(self, axis=0, *, numeric_only: bool = False): """ Return the product of the values over the requested axis. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame({"A": [1, 2, 3], "B": [4.5, 5.5, 6.5]}) + >>> df + + Calculating the product of each column(the default). + + >>> df.prod() + A 6.0 + B 160.875 + dtype: Float64 + + Calculating the product along the rows. + + >>> df.prod(axis=1) + 0 4.5 + 1 11.0 + 2 19.5 + dtype: Float64 + Args: - aßxis ({index (0), columns (1)}): + axis ({index (0), columns (1)}): Axis for the function to be applied on. For Series this parameter is unused and defaults to 0. numeric_only (bool. default False): From 109cba4b96b3a958fb7803cc5a3573c0a4a2edb8 Mon Sep 17 00:00:00 2001 From: Huan Chen Date: Tue, 21 Nov 2023 19:56:22 +0000 Subject: [PATCH 2/3] Update examples --- third_party/bigframes_vendored/pandas/core/frame.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/third_party/bigframes_vendored/pandas/core/frame.py b/third_party/bigframes_vendored/pandas/core/frame.py index 4598a5321f..92ffbb0e7b 100644 --- a/third_party/bigframes_vendored/pandas/core/frame.py +++ b/third_party/bigframes_vendored/pandas/core/frame.py @@ -2597,7 +2597,7 @@ def any(self, *, axis=0, bool_only: bool = False): [2 rows x 2 columns] - Checking if each column contains at least one True element(the default). + Checking if each column contains at least one True element(the default behavior without an explicit axis parameter). >>> df.any() A True @@ -2644,7 +2644,7 @@ def all(self, axis=0, *, bool_only: bool = False): [2 rows x 2 columns] - Checking if all values in each column are True(the default). + Checking if all values in each column are True(the default behavior without an explicit axis parameter). >>> df.all() A True @@ -2682,14 +2682,14 @@ def prod(self, axis=0, *, numeric_only: bool = False): >>> df = bpd.DataFrame({"A": [1, 2, 3], "B": [4.5, 5.5, 6.5]}) >>> df - Calculating the product of each column(the default). + Calculating the product of each column(the default behavior without an explicit axis parameter). >>> df.prod() A 6.0 B 160.875 dtype: Float64 - Calculating the product along the rows. + Calculating the product of each row. >>> df.prod(axis=1) 0 4.5 From e966c72e7cb5a52dae4ea6635a7b5a3d1732cbe2 Mon Sep 17 00:00:00 2001 From: Huan Chen Date: Tue, 21 Nov 2023 21:30:56 +0000 Subject: [PATCH 3/3] update example output --- third_party/bigframes_vendored/pandas/core/frame.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/third_party/bigframes_vendored/pandas/core/frame.py b/third_party/bigframes_vendored/pandas/core/frame.py index 92ffbb0e7b..693ae1d285 100644 --- a/third_party/bigframes_vendored/pandas/core/frame.py +++ b/third_party/bigframes_vendored/pandas/core/frame.py @@ -2681,6 +2681,12 @@ def prod(self, axis=0, *, numeric_only: bool = False): >>> df = bpd.DataFrame({"A": [1, 2, 3], "B": [4.5, 5.5, 6.5]}) >>> df + A B + 0 1 4.5 + 1 2 5.5 + 2 3 6.5 + + [3 rows x 2 columns] Calculating the product of each column(the default behavior without an explicit axis parameter).