1# (1) Round to specific decimal places – Single DataFrame column
2df['DataFrame column'].round(decimals=number of decimal places needed)
3
4# (2) Round up – Single DataFrame column
5df['DataFrame column'].apply(np.ceil)
6
7# (3) Round down – Single DataFrame column
8df['DataFrame column'].apply(np.floor)
9
10# (4) Round to specific decimals places – Entire DataFrame
11df.round(decimals=number of decimal places needed)
1#Option 1
2In [661]: df.round({'Y': 2, 'X': 2})
3Out[661]:
4 Y X id WP_NER
50 35.97 -2.73 1 WP_01
61 35.59 -2.90 2 WP_02
72 35.33 -3.39 3 WP_03
83 35.39 -3.93 4 WP_04
94 35.58 -3.94 5 WP_05
105 35.52 -3.41 6 WP_06
116 35.76 -3.08 7 WP_07
12
13#Option 2
14In [662]: cols = ['Y', 'X']
15In [663]: df[cols] = df[cols].round(2)