I've tried changing GPA decimal to 1 decimal point:
df['Admission GPA'].round(decimals = 1)
#df.round({"Admission GPA":1})
Which prints it out how i want it to:
0 3.2
1 2.9
2 2.7
3 3.2
4 2.4
...
126 1.6
127 2.8
128 3.0
129 2.7
130 2.4
Name: Admission GPA, Length: 131, dtype: float64
However when I print the column to see if it made changes in the dataframe I notice it is still in 2 decimal points:
0 3.19
1 2.93
2 2.68
3 3.18
4 2.36
...
126 1.59
127 2.85
128 3.03
129 2.72
130 2.45
Name: Admission GPA, Length: 131, dtype: float64
CodePudding user response:
You are not assigning the result back to the column.
df['Admission GPA'] = df['Admission GPA'].round(decimals = 1)
The pd.Series.round()
function does not perform the operation in-place; it returns a new pd.Series
which you must reassign to the column in your dataframe.