【发布时间】:2020-05-17 02:11:23
【问题描述】:
df
Col1 Col2 Col3
12 10 3
3 5 2
100 12 10
等等……
为时间序列中的 ARIMA 建模编写更全面的测试的代码。 (将为数据框df的所有列计算p值)
import statsmodels.tsa.stattools as tsa
adf_results = {}
for col in df.columns.values:
adf_results[col] = tsa.adfuller(df[col])
使用此代码,我得到以下格式的输出:(输入 adf_result 时的输出)
[IN] adf_result
[OUT]
{'Col1': (-4.236149193618492,
0.0005719678593039654, #This is the second value for this column/p value
0,
37,
{'1%': -3.6209175221605827,
'5%': -2.9435394610388332,
'10%': -2.6104002410518627},
138.66116123406837),
'Col2': (-3.707023043984407,
0.004015446231411924, #This is the second value for this column/p value
0,
37,
{'1%': -3.6209175221605827,
'5%': -2.9435394610388332,
'10%': -2.6104002410518627},
144.6019873130419),
'Col3': (1.8083888603589304,
0.9983655107052215, #This is the second value for this column/p value
0,
37,
{'1%': -3.6209175221605827,
'5%': -2.9435394610388332,
'10%': -2.6104002410518627},
-74.4384052778039)}
等等。
在这个问题中,第二个值/p值是
0.0005719678593039654, 0.004015446231411924 and 0.9983655107052215 for the 3 columns taken.
我需要一个列表中第二个值 >0.05 的列和另一个列表中 p 值
所以一个列表将是 col1 和 col2(第二个值/p 值
【问题讨论】:
-
也许这会对你有所帮助?它刚刚发布... stackoverflow.com/questions/60003381/…
-
list_a = [k for k, v in adf_result.items() if v[1] <= 0.05]和list_b = [k for k, v in adf_result.items() if v[1] > 0.05]...?
标签: python pandas machine-learning time-series arima