@@ -3434,7 +3434,26 @@ def melt(self, id_vars, value_vars, var_name, value_name):
3434
3434
3435
3435
def nunique (self ):
3436
3436
"""
3437
- Count number of distinct elements in specified axis.
3437
+ Count number of distinct elements in each column.
3438
+
3439
+ **Examples:**
3440
+
3441
+ >>> import bigframes.pandas as bpd
3442
+ >>> bpd.options.display.progress_bar = None
3443
+
3444
+ >>> df = bpd.DataFrame({"A": [3, 1, 2], "B": [1, 2, 2]})
3445
+ >>> df
3446
+ A B
3447
+ 0 3 1
3448
+ 1 1 2
3449
+ 2 2 2
3450
+ <BLANKLINE>
3451
+ [3 rows x 2 columns]
3452
+
3453
+ >>> df.nunique()
3454
+ A 3.0
3455
+ B 2.0
3456
+ dtype: Float64
3438
3457
3439
3458
Returns:
3440
3459
bigframes.series.Series: Series with number of distinct elements.
@@ -3578,6 +3597,40 @@ def diff(
3578
3597
Calculates the difference of a DataFrame element compared with another
3579
3598
element in the DataFrame (default is element in previous row).
3580
3599
3600
+ **Examples:**
3601
+
3602
+ >>> import bigframes.pandas as bpd
3603
+ >>> bpd.options.display.progress_bar = None
3604
+
3605
+ >>> df = bpd.DataFrame({"A": [3, 1, 2], "B": [1, 2, 3]})
3606
+ >>> df
3607
+ A B
3608
+ 0 3 1
3609
+ 1 1 2
3610
+ 2 2 3
3611
+ <BLANKLINE>
3612
+ [3 rows x 2 columns]
3613
+
3614
+ Calculating difference with default periods=1:
3615
+
3616
+ >>> df.diff()
3617
+ A B
3618
+ 0 <NA> <NA>
3619
+ 1 -2 1
3620
+ 2 1 1
3621
+ <BLANKLINE>
3622
+ [3 rows x 2 columns]
3623
+
3624
+ Calculating difference with periods=-1:
3625
+
3626
+ >>> df.diff(periods=-1)
3627
+ A B
3628
+ 0 2 -1
3629
+ 1 -1 -1
3630
+ 2 <NA> <NA>
3631
+ <BLANKLINE>
3632
+ [3 rows x 2 columns]
3633
+
3581
3634
Args:
3582
3635
periods (int, default 1):
3583
3636
Periods to shift for calculating difference, accepts negative
@@ -3590,7 +3643,37 @@ def diff(
3590
3643
3591
3644
def agg (self , func ):
3592
3645
"""
3593
- Aggregate using one or more operations over the specified axis.
3646
+ Aggregate using one or more operations over columns.
3647
+
3648
+ **Examples:**
3649
+
3650
+ >>> import bigframes.pandas as bpd
3651
+ >>> bpd.options.display.progress_bar = None
3652
+
3653
+ >>> df = bpd.DataFrame({"A": [3, 1, 2], "B": [1, 2, 3]})
3654
+ >>> df
3655
+ A B
3656
+ 0 3 1
3657
+ 1 1 2
3658
+ 2 2 3
3659
+ <BLANKLINE>
3660
+ [3 rows x 2 columns]
3661
+
3662
+ Using a single function:
3663
+
3664
+ >>> df.agg('sum')
3665
+ A 6.0
3666
+ B 6.0
3667
+ dtype: Float64
3668
+
3669
+ Using a list of functions:
3670
+
3671
+ >>> df.agg(['sum', 'mean'])
3672
+ A B
3673
+ sum 6.0 6.0
3674
+ mean 2.0 2.0
3675
+ <BLANKLINE>
3676
+ [2 rows x 2 columns]
3594
3677
3595
3678
Args:
3596
3679
func (function):
@@ -3623,6 +3706,33 @@ def describe(self):
3623
3706
upper percentile is ``75``. The ``50`` percentile is the
3624
3707
same as the median.
3625
3708
3709
+ **Examples:**
3710
+
3711
+ >>> import bigframes.pandas as bpd
3712
+ >>> bpd.options.display.progress_bar = None
3713
+
3714
+ >>> df = bpd.DataFrame({"A": [3, 1, 2], "B": [0, 2, 8]})
3715
+ >>> df
3716
+ A B
3717
+ 0 3 0
3718
+ 1 1 2
3719
+ 2 2 8
3720
+ <BLANKLINE>
3721
+ [3 rows x 2 columns]
3722
+
3723
+ >>> df.describe()
3724
+ A B
3725
+ count 3.0 3.0
3726
+ mean 2.0 3.333333
3727
+ std 1.0 4.163332
3728
+ min 1.0 0.0
3729
+ 25% 1.0 0.0
3730
+ 50% 2.0 2.0
3731
+ 75% 3.0 8.0
3732
+ max 3.0 8.0
3733
+ <BLANKLINE>
3734
+ [8 rows x 2 columns]
3735
+
3626
3736
Returns:
3627
3737
bigframes.dataframe.DataFrame: Summary statistics of the Series or Dataframe provided.
3628
3738
"""
0 commit comments