Heat map for Correlation

This works-

Cor= Winedata.corr()
#print(Cor)
correlations = Winedata.corr()[‘alcohol’].drop(‘alcohol’)
#print(correlations)

sns.heatmap(Winedata.corr())
plt.show()

However, when we try to pass correlations variable to see the heat map after quality target value is dropped- the below code doesn’t work. Please explain.

Cor= Winedata.corr()
#print(Cor)
correlations = Winedata.corr()[‘alcohol’].drop(‘alcohol’)
#print(correlations)

sns.heatmap(correlations)
or
sns.heatmap(Winedata.corr()[‘alcohol’].drop(‘alcohol’))
plt.show()

Hi, Sugandhita.

  1. sns.heatmap(Winedata.corr())

Kindly check the datatype of the "Winedata.corr() " this should be a pandas dataframe type and hence you can apply the heatmap() function on it.

correlations=Winedata.corr()[‘alcohol’].drop(‘alcohol’)

This is a pandas series type and heatmap() function will not accepts as it accepts a 2D dataframe type.
or “alcohol” columns may not be present.

The above may be the primary reason.
Kindly send the error screenshots to get more insights.

All the best!