生成一个数据帧的系列计算,以提供NaN占行总数的百分比,如下所示:
data = df.isnull().sum()/len(df)*100
RecordID 0.000000
ContactID 0.000000
EmailAddress 0.000000
ExternalID 100.000000
Date 0.000000
Name 0.000000
Owner 67.471362
Priority 0.000000
Status 0.000000
Subject 0.000000
Description 0.000000
Type 0.000000
dtype: float64
我最想做的是把它作为seaborn sns.heatmap(data)
的热图,吸引读者注意那些100%和67%的人,不幸的是我得到了这个错误
IndexError: Inconsistent shape between the condition and the input (got (12, 1) and (12,))
完全回溯:
^{pr2}$我的研究,如果撞上了很多关于numpy广播规则的墙,或者是3年前的一个bug——这些都没有一个是超级有用的。在
一如既往的感谢。在
您的
data
变量是pd.Series
的一个实例,它本质上是1D,sns.heatmap
需要2D输入。例如,快速修复方法如下:相关问题 更多 >
编程相关推荐