Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ch.2 Error using corr() #686

Open
rejgrant opened this issue Oct 21, 2023 · 3 comments
Open

Ch.2 Error using corr() #686

rejgrant opened this issue Oct 21, 2023 · 3 comments

Comments

@rejgrant
Copy link

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
Copy link

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

@jyothissJayadev
Copy link

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)

@Pandemonium9
Copy link

Here is the correct way after scikit updated

corr_matrix = housing.corr(numeric_only = True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants