ageron / ageron/handson-ml2

[BUG] [Chapter2] ValueError when calculating the correlations in corr_matrix = housing.corr()

Open
#614 4 comments 10 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
30k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

The following ValueError occurs when calling

`corr_matrix = housing.corr()`

**ValueError: could not convert string to float: 'INLAND'**

Obviously the DataFrame gets confused by the values in "ocean_proximity"

For me the solution was to change the 2 lines were the correlations are calculated to:

`corr_matrix = housing.corr(numeric_only=True)`

According to:

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.corr.html

The default value of numeric_only for DataFrame.corr() was changed to False effective as of pandas 2.0.0

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.