我使用 lambda 以下函数将缺失值替换为 NaN:
data = data.applymap(lambda x: np.nan if isinstance(x, basestring) and x.isspace() else x)
where data
是我正在处理的数据框。
Using seaborn
之后,我尝试绘制它的属性之一,'alcconsumption'
, using seaborn.distplot
如下:
seaborn.distplot(data['alcconsumption'],hist=True,bins=100)
plt.xlabel('AlcoholConsumption')
plt.ylabel('Frequency(normalized 0->1)')
它给了我以下错误:
AttributeError: max must be larger than min in range parameter.
您可以使用以下行使用seaborn为分布图选择非NaN值:
seaborn.distplot(data['alcconsumption'].notnull(),hist=True,bins=100)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)