handson-ml icon indicating copy to clipboard operation
handson-ml copied to clipboard

Ch.2 Error using corr()

Open rejgrant opened this issue 1 year ago • 3 comments

I am getting the following error while using corr_matrix = housing.corr(), I know the method should exclude non-numerical columns, can't understand this error. " ValueError: could not convert string to float: 'INLAND' "

rejgrant avatar Oct 21 '23 14:10 rejgrant

Try this:- housing_encoded = pd.get_dummies(housing, columns=['INLAND'], drop_first=True) corr_matrix = housing_encoded.corr()

khushi-98 avatar Jan 28 '24 11:01 khushi-98

TRY THIS WAY

housing_encoded = pd.get_dummies(housing, columns=['ocean_proximity'], drop_first=True) corr_matrix = housing_encoded.corr() corr_matrix["median_house_value"].sort_values(ascending=False)

jyothissJayadev avatar Jun 02 '24 10:06 jyothissJayadev