【发布时间】:2018-04-08 17:27:32
【问题描述】:
我需要为具有空白值的数据集绘制计数图。我尝试使用
sns.countplot(x='ViolLevel',data=df1)
但它正在绘制值enter image description here
但这并没有显示数据中空值的计数。
但是
df1['ViolLevel'].isnull().sum()
给我 29740 的输出。
如何在计数图中包含 nan 值?
【问题讨论】:
我需要为具有空白值的数据集绘制计数图。我尝试使用
sns.countplot(x='ViolLevel',data=df1)
但它正在绘制值enter image description here
但这并没有显示数据中空值的计数。
但是
df1['ViolLevel'].isnull().sum()
给我 29740 的输出。
如何在计数图中包含 nan 值?
【问题讨论】:
您可以用字符串替换数据集中的空值并再次运行绘图:
df1.ViolLevel.fillna('Null', inplace=True)
【讨论】: