campusx-official / 100-days-of-machine-learning

1.22k stars 1.63k forks source link

issue in df.corr() in day 19 class #43

Open shadab12py opened 3 months ago

shadab12py commented 3 months ago

this show this bug , ValueError: could not convert string to float: 'Braund, Mr. Owen Harris' . plz suggest a sol Screenshot (80)

stoicsapien1 commented 3 months ago

Use df.corr(numeric_only=True)

yaswanthreddy3 commented 3 months ago

Use df.corr(numeric_only=True)

saumyayadav25 commented 3 months ago
numeric_columns = ['PassengerId', 'Survived', 'Pclass', 'Age', 'SibSp', 'Parch', 'Fare']
correlation_matrix = df[numeric_columns].corr()

use df.corr for numerical data only. The above code should work