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?
CodePudding user response:
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)
CodePudding user response:
Why not use
pandas.DataFrame.round
Official documentation about the function: pandas.DataFrame.round