seaborn distplot类型错误

时间:2017-11-02 15:26:20

标签: python seaborn

我的数据集如下:

train['SalePrice'].head()
0    208500
1    181500
2    223500
3    140000
4    250000
Name: SalePrice, dtype: int64

我想使用seaborn.distplot(train [' SalePrice'])绘制它,但会显示以下错误。

    ---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-94-00861be8ee63> in <module>()
      1 #SalePrice
----> 2 sns.distplot(train['SalePrice'])
      3 #train['SalePrice'].head()

/usr/lib/python3/dist-packages/seaborn/distributions.py in distplot(a, bins, hist, kde, rug, fit, hist_kws, kde_kws, rug_kws, fit_kws, color, vertical, norm_hist, axlabel, label, ax)
    210         hist_color = hist_kws.pop("color", color)
    211         ax.hist(a, bins, orientation=orientation,
--> 212                 color=hist_color, **hist_kws)
    213         if hist_color != color:
    214             hist_kws["color"] = hist_color

/usr/lib/python3/dist-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
   1812                     warnings.warn(msg % (label_namer, func.__name__),
   1813                                   RuntimeWarning, stacklevel=2)
-> 1814             return func(ax, *args, **kwargs)
   1815         pre_doc = inner.__doc__
   1816         if pre_doc is None:

/usr/lib/python3/dist-packages/matplotlib/axes/_axes.py in hist(self, x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, **kwargs)
   6008             # this will automatically overwrite bins,
   6009             # so that each histogram uses the same bins
-> 6010             m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs)
   6011             m = m.astype(float)  # causes problems later if it's an int
   6012             if mlast is None:

/usr/local/lib/python3.5/dist-packages/numpy/lib/function_base.py in histogram(a, bins, range, normed, weights, density)
    727 
    728         # Initialize empty histogram
--> 729         n = np.zeros(bins, ntype)
    730         # Pre-compute histogram scaling factor
    731         norm = bins / (mx - mn)

TypeError: 'numpy.float64' object cannot be interpreted as an integer

我不明白这里的类型错误是什么。 Python版本:3.5.2 Seaborn版本:0.6.0。

0 个答案:

没有答案