ageron / handson-ml

⛔️ DEPRECATED – See https://github.com/ageron/handson-ml3 instead.
Apache License 2.0
25.12k stars 12.91k forks source link

Ch.2 Error using corr() #686

Open rejgrant opened 8 months ago

rejgrant commented 8 months ago

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' "

khushi-98 commented 5 months ago

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

jyothissJayadev commented 1 month ago

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)