Skip to content

Commit d7957fa

Browse files
authored
docs: code samples for dataframe.any, dataframe.all and dataframe.prod (#223)
* docs: code samples for dataframe.any, dataframe.all and dataframe.prod * Update examples * update example output
1 parent ed8876d commit d7957fa

File tree

1 file changed

+84
-1
lines changed
  • third_party/bigframes_vendored/pandas/core

1 file changed

+84
-1
lines changed

‎third_party/bigframes_vendored/pandas/core/frame.py

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2584,6 +2584,33 @@ def any(self, *, axis=0, bool_only: bool = False):
25842584
along a Dataframe axis that is True or equivalent (e.g. non-zero or
25852585
non-empty).
25862586
2587+
**Examples:**
2588+
2589+
>>> import bigframes.pandas as bpd
2590+
>>> bpd.options.display.progress_bar = None
2591+
2592+
>>> df = bpd.DataFrame({"A": [True, True], "B": [False, False]})
2593+
>>> df
2594+
A B
2595+
0 True False
2596+
1 True False
2597+
<BLANKLINE>
2598+
[2 rows x 2 columns]
2599+
2600+
Checking if each column contains at least one True element(the default behavior without an explicit axis parameter).
2601+
2602+
>>> df.any()
2603+
A True
2604+
B False
2605+
dtype: boolean
2606+
2607+
Checking if each row contains at least one True element.
2608+
2609+
>>> df.any(axis=1)
2610+
0 True
2611+
1 True
2612+
dtype: boolean
2613+
25872614
Args:
25882615
axis ({index (0), columns (1)}):
25892616
Axis for the function to be applied on.
@@ -2604,6 +2631,33 @@ def all(self, axis=0, *, bool_only: bool = False):
26042631
along a DataFrame axis that is False or equivalent (e.g. zero or
26052632
empty).
26062633
2634+
**Examples:**
2635+
2636+
>>> import bigframes.pandas as bpd
2637+
>>> bpd.options.display.progress_bar = None
2638+
2639+
>>> df = bpd.DataFrame({"A": [True, True], "B": [False, False]})
2640+
>>> df
2641+
A B
2642+
0 True False
2643+
1 True False
2644+
<BLANKLINE>
2645+
[2 rows x 2 columns]
2646+
2647+
Checking if all values in each column are True(the default behavior without an explicit axis parameter).
2648+
2649+
>>> df.all()
2650+
A True
2651+
B False
2652+
dtype: boolean
2653+
2654+
Checking across rows to see if all values are True.
2655+
2656+
>>> df.all(axis=1)
2657+
0 False
2658+
1 False
2659+
dtype: boolean
2660+
26072661
Args:
26082662
axis ({index (0), columns (1)}):
26092663
Axis for the function to be applied on.
@@ -2620,8 +2674,37 @@ def prod(self, axis=0, *, numeric_only: bool = False):
26202674
"""
26212675
Return the product of the values over the requested axis.
26222676
2677+
**Examples:**
2678+
2679+
>>> import bigframes.pandas as bpd
2680+
>>> bpd.options.display.progress_bar = None
2681+
2682+
>>> df = bpd.DataFrame({"A": [1, 2, 3], "B": [4.5, 5.5, 6.5]})
2683+
>>> df
2684+
A B
2685+
0 1 4.5
2686+
1 2 5.5
2687+
2 3 6.5
2688+
<BLANKLINE>
2689+
[3 rows x 2 columns]
2690+
2691+
Calculating the product of each column(the default behavior without an explicit axis parameter).
2692+
2693+
>>> df.prod()
2694+
A 6.0
2695+
B 160.875
2696+
dtype: Float64
2697+
2698+
Calculating the product of each row.
2699+
2700+
>>> df.prod(axis=1)
2701+
0 4.5
2702+
1 11.0
2703+
2 19.5
2704+
dtype: Float64
2705+
26232706
Args:
2624-
aßxis ({index (0), columns (1)}):
2707+
axis ({index (0), columns (1)}):
26252708
Axis for the function to be applied on.
26262709
For Series this parameter is unused and defaults to 0.
26272710
numeric_only (bool. default False):

0 commit comments

Comments
 (0)