@@ -4788,6 +4788,83 @@ def merge(
4788
4788
"""
4789
4789
raise NotImplementedError (constants .ABSTRACT_METHOD_ERROR_MESSAGE )
4790
4790
4791
+ def round (self , decimals ):
4792
+ """
4793
+ Round a DataFrame to a variable number of decimal places.
4794
+
4795
+ **Examples:**
4796
+
4797
+ >>> import bigframes.pandas as bpd
4798
+ >>> bpd.options.display.progress_bar = None
4799
+ >>> df = bpd.DataFrame([(.21, .32), (.01, .67), (.66, .03), (.21, .18)],
4800
+ ... columns=['dogs', 'cats'])
4801
+ >>> df
4802
+ dogs cats
4803
+ 0 0.21 0.32
4804
+ 1 0.01 0.67
4805
+ 2 0.66 0.03
4806
+ 3 0.21 0.18
4807
+ <BLANKLINE>
4808
+ [4 rows x 2 columns]
4809
+
4810
+ By providing an integer each column is rounded to the same number
4811
+ of decimal places
4812
+
4813
+ >>> df.round(1)
4814
+ dogs cats
4815
+ 0 0.2 0.3
4816
+ 1 0.0 0.7
4817
+ 2 0.7 0.0
4818
+ 3 0.2 0.2
4819
+ <BLANKLINE>
4820
+ [4 rows x 2 columns]
4821
+
4822
+ With a dict, the number of places for specific columns can be
4823
+ specified with the column names as key and the number of decimal
4824
+ places as value
4825
+
4826
+ >>> df.round({'dogs': 1, 'cats': 0})
4827
+ dogs cats
4828
+ 0 0.2 0.0
4829
+ 1 0.0 1.0
4830
+ 2 0.7 0.0
4831
+ 3 0.2 0.0
4832
+ <BLANKLINE>
4833
+ [4 rows x 2 columns]
4834
+
4835
+ Using a Series, the number of places for specific columns can be
4836
+ specified with the column names as index and the number of
4837
+ decimal places as value
4838
+
4839
+ >>> decimals = pd.Series([0, 1], index=['cats', 'dogs'])
4840
+ >>> df.round(decimals)
4841
+ dogs cats
4842
+ 0 0.2 0.0
4843
+ 1 0.0 1.0
4844
+ 2 0.7 0.0
4845
+ 3 0.2 0.0
4846
+ <BLANKLINE>
4847
+ [4 rows x 2 columns]
4848
+
4849
+ Args:
4850
+ decimals (int, dict, Series):
4851
+ Number of decimal places to round each column to. If an int is
4852
+ given, round each column to the same number of places.
4853
+ Otherwise dict and Series round to variable numbers of places.
4854
+ Column names should be in the keys if `decimals` is a
4855
+ dict-like, or in the index if `decimals` is a Series. Any
4856
+ columns not included in `decimals` will be left as is. Elements
4857
+ of `decimals` which are not columns of the input will be
4858
+ ignored.
4859
+
4860
+ Returns:
4861
+ bigframes.pandas.DataFrame:
4862
+ A DataFrame with the affected columns rounded to the specified
4863
+ number of decimal places.
4864
+
4865
+ """
4866
+ raise NotImplementedError (constants .ABSTRACT_METHOD_ERROR_MESSAGE )
4867
+
4791
4868
def apply (self , func , * , axis = 0 , args = (), ** kwargs ):
4792
4869
"""Apply a function along an axis of the DataFrame.
4793
4870
0 commit comments