0

My data frame includes both float and binary dummy variables. When trying to create a correlation heatmap, the .corr() function creates the correlation matrix only for my binary variables and eliminates the rest. I wonder if there's a reason for this odd behavior and how to fix the problem/use a different package to create correlation matrix.

Here is the codes I use:

# Heatmap

import seaborn as sns
import matplotlib.pyplot as plt
cols_noCluster= df1.columns
df_noCluster = df1[cols_noCluster]
corr = df_noCluster.corr()

f, ax = plt.subplots(figsize=(17, 17))
hm = sns.heatmap(round(corr,2), annot=True, ax=ax, #cmap="coolwarm",
                 fmt='.2f',linewidths=.05)

bottom, top = ax.get_ylim()
ax.set_ylim(bottom + 0.5, top - 0.5)

f.subplots_adjust(top=0.93)
t= f.suptitle('Correlation Heatmap', fontsize=14)

Thanks

Z-B
  • 31
  • 2
  • Can you post some example code, including a (small) dataframe which reproduces the problem? Having a [MCVE](https://stackoverflow.com/help/minimal-reproducible-example) will help others answer your question. – Nick ODell Oct 05 '20 at 04:54
  • Please post your data frame (assume its name is `df`) and show `df.dtypes`. Do not paste screenshots. How to paste: https://stackoverflow.com/questions/20109391 – Bill Huang Oct 05 '20 at 07:20

0 Answers0