Examples
import numpy as np
import pandas as pd
df = pd.DataFrame([(.24, .34), (.02, .70), (.64, .04), (.24, .20)],
columns=['deers', 'goats'])
df
By providing an integer each column is rounded to the same number of decimal places:
df.round(1)
With a dict, the number of places for specific columns can be specified with the column
names as key and the number of decimal places as value:
df.round({'deers': 1, 'goats': 0})
Using a Series, the number of places for specific columns can be specified with the column
names as index and the number of decimal places as value:
decimals = pd.Series([0, 1], index=['deers', 'goats'])
df.round(decimals)