在isnu上计算出生于海洋的大Pandas热图

2024-04-29 09:46:55 发布

您现在位置:Python中文网/ 问答频道 /正文

生成一个数据帧的系列计算,以提供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——这些都没有一个是超级有用的。在

一如既往的感谢。在


Tags: andthe数据dfdatalennan百分比