您好我正在尝试对数据样本使用bootstrap_plot()函数,但遇到以下错误。我使用相同的数据数组来绘制直方图,使用matplotlibs hist()函数没有问题。
Traceback (most recent call last):
File "/home/Astrophysics/BootStrapping.py", line 19, in <module>
bootstrap_plot(C, size=17517, samples=1000, color='grey')
File "/usr/local/lib/python2.7/dist-packages/pandas-0.8.2.dev_eec8a83-py2.7- linux- i686.egg/pandas/tools/plotting.py", line 301, in bootstrap_plot
data = series.values
AttributeError: 'numpy.ndarray' object has no attribute 'values'
我的代码
import matplotlib.pyplot as plt
import numpy as np
import scipy
import matplotlib.mlab as mlab
import statsmodels.api as sm
import pyfits
from pandas.tools.plotting import bootstrap_plot
F = '/home/khary/Astrophysics/outfiles/outmag20_2dr_9_658.txt'
#data_cube ,header_data_cube = pyfits.getdata("/home/Astrophysics/SDSS_Counts /count.dr72bright0.3dlz01r01c06.0.fits",1,header=True)
#load arrays with data
data=np.loadtxt(F)
C=data[:,3]
#obs_count = data_cube.field(3)
#Bootstrap plot
bootstrap_plot(C, size=17517, samples=1000, color='grey')
plt.show()
答案 0 :(得分:2)
Pandas bootstrap_plot期望系列作为第一个参数。
from pandas import Series
bootstrap_plot(Series(C), size=17517, samples=1000, color='grey')