【发布时间】:2021-03-04 13:33:03
【问题描述】:
此程序显示错误以获取 rollingmean 输出。
dff = pd.Series([ 0.001215,0.001571,0.002944, 0.005101, 0.007357, 0.009988, 0.013653, 0.017936, 0.021971, 0.025590 ])
dff = pd.DataFrame(dff, columns=['A'])
avg = dff['A'].rolling(3).mean()
avg = [x*5 for x in avg]
dff['mean'] = avg
listpos = 0 #We use a counter to move over the different data columns
for datapoint in dff.A:
rollingmean = dff.mean[listpos]
模拟后给出如下错误信息:
TypeError Traceback (most recent call last)
<ipython-input-114-61e9145fea85> in <module>()
13 for datapoint in dff.A:
---> 14 rollingmean = dff.mean[listpos] #Get local mean
TypeError: 'method' object is not subscriptable
这段代码有什么问题?
【问题讨论】:
标签: python pandas dataframe csv for-loop