Extract P Values In A List For Adfuller Test(test For Stationarity) In Arima Time Series Modeling Python Pandas
df Col1 Col2 Col3 12 10 3 3 5 2 100 12 10 and so on..... Code to write adfuller test for ARIMA modeling in Time series. (will calculate p value
Solution 1:
import pandas as pd
from io import StringIO
data = StringIO("""
Col1 Col2 Col3
12 10 3
3 5 2
100 12 10
13 4 1
""")
# load data into data frame
df = pd.read_csv(data, sep=' ')
import statsmodels.tsa.stattools as tsa
adf_results = {}
for col in df.columns.values:
adf_results[col] = tsa.adfuller(df[col])
# loop over dictionary data
columns_big = []
columns_small = []
for key, value in adf_results.items():
if value[1] > 0.05:
columns_big.append(key)
else:
columns_small.append(key)
Output:
columns_big = ['Col1', 'Col3']
columns_small = ['Col2']
Post a Comment for "Extract P Values In A List For Adfuller Test(test For Stationarity) In Arima Time Series Modeling Python Pandas"