【发布时间】:2019-05-16 21:27:27
【问题描述】:
您好,我真的很想创建一个热图,但我很挣扎:
# correlations between undergrad studies and occupation
data_uni = n.groupby(['Q5','Q6'])['Q6'].count().to_frame(name = 'count').reset_index()
# some participants did not answer the question in the survey
data_uni.fillna('Unknown', inplace=True)
data_uni.pivot(index='Q5', columns='Q6', values='count')
plt.figure(1, figsize=(14,10))
sns.heatmap(data_uni, cmap="YlGnBu")
我得到的错误信息是 "TypeError: ufunc 'isnan' not supported for the input types, and the input could not be safe to becovered to any supported types based on the cast rule ''safe''"。
这是创建热图的正确方法吗?如果是,我做错了什么,如果不是,正确的方法是什么?谢谢您的帮助!
【问题讨论】:
标签: python pandas seaborn nan heatmap