Rounding off to two decimal places

Viewed 58
corr_matrix = data.corr()
corr_matrix.sort_values('SalePrice', ascending = False, inplace = True)

print(corr_matrix.SalePrice)

How do i alter my code so that I can round off the answers to 2 decimal places?

2 Answers

simply use .round()

corr_matrix = data.corr()
corr_matrix = corr_matrix.round(2) #<-- as I posted in the comments
corr_matrix.sort_values('SalePrice', ascending = False, inplace = True)

print(corr_matrix.SalePrice)
Related