我已经提取了这个数据帧,并在其中添加了datetime
问题是我有一个函数是可写的
当我检查数据帧时,它是可编辑的
if hasattr(df_raw, '__iter__'):
print(f'{df_raw} is iterable')
这就是结果[1508行x 1列]是可编辑的
我不知道怎么了, 功能似乎还可以
有人能帮我吗
这是功能代码和下面的代码
def fracDiff_FFD(series,d,thres=1e-5):
#1)Compute weights for the longest series
w=getWeights_FFD(d,thres)
width= len(w)-1
#2)Apply weights to values
df={}
for i in series:
seriesF=series[[i]].fillna(method='ffill').dropna()
df_=pd.Series()
for iloc1 in range(width, seriesF.shape[0]):
loc0,loc1=seriesF.index[iloc1-width],seriesF.index[iloc1]
if not np.isfinite(series.loc[loc1,name]):continue #exlcude NAs
df_[loc1]=np.dot(w.T,seriesF.loc[loc0:loc1])[0,0]
df[name]=df_.copy(deep=True)
df=pd.concat(df,axis=1)
return df
# plotMinFFD()
##Dickey Fuller test
# print(df00.values.any())
df_raw = df00[['Close']]
下面是控制台结果和错误提示
Close
Datetime
2015-01-05 2.167526
2015-01-06 2.036082
2015-01-07 2.148196
2015-01-08 2.411082
2015-01-09 2.333763
...
NaT 9.740979
NaT 9.719716
NaT 9.779639
NaT 9.781572
NaT 9.746778
[1508 rows x 1 columns] is iterable
Traceback (most recent call last):
File "C:\Studies\Capstone 2\ReadCsv.py", line 781, in <module>
df01=fracDiff_FFD(df_raw.all, d=0.1,thres=0.01)
File "C:\Studies\Capstone 2\ReadCsv.py", line 732, in fracDiff_FFD
for i in series:
TypeError: 'method' object is not iterable
df_raw.isnull().values.any()
if hasattr(df_raw, '__iter__'):
print(f'{df_raw} is iterable')
df01=fracDiff_FFD(df_raw.all, d=0.1,thres=0.01)
我不知道是什么问题
目前没有回答
相关问题 更多 >
编程相关推荐