当系列中有NaN值时,就会发生此错误。可能是这样吗?
histmatplotlib的功能无法很好地处理这些NaN 。例如:
s = pd.Series([1,2,3,2,2,3,5,2,3,2,np.nan])fig, ax = plt.subplots()ax.hist(s, alpha=0.9, color='blue')
产生相同的错误
AttributeError: max must be larger than min in rangeparameter.一种选择是例如在绘图前去除NaN。这将起作用:
ax.hist(s.dropna(), alpha=0.9, color='blue')
另一种选择是使用大熊猫
hist在你的一系列方法和提供
axes[0]的
ax关键字:
dfj2_MARKET1['VSPD1_perc'].hist(ax=axes[0], alpha=0.9, color='blue')



