First: thank you for the great help so far! I have a question on working with table formatting in iPython.
I currently run this script to print the Augmented Dickey-Fuller (ADF) Test for Stationarity:
print "Stationarity"
print sm.tsa.stattools.adfuller(df['temperature'], maxlag=None, autolag='BIC', regression='c')
The output is something like this:
Stationarity
(-6.4532219513246361, 1.5054094590984612e-08, 0, 41, {'5%': -2.9351348158036012, '1%': -3.6009833671885199, '10%': -2.6059629803688282}, 1227.2605520289471*)
*(not sure what this value is Link to Documentation)
Now, my questions are:
How can I automate the calculation for more than one variable? Is it possible to create a list containing the different columns (df['variable1'], df['variable1'], df['variable1'], df['variable1'], ...) that applies the ADF test for each item?
How can I put the returning data into a table structure? Something like this:
ADF Test
Variable nobs t-test p-value 1% 5% 10% temperature 41 6.4532 1.5054094590984612e-08 -3.600 -2.9351 -2.6059 variable 2 ... variable 3 ...
(By the way: How to convert "1.5054094590984612e-08" into an accurate number?)
Thanks for your support!
col_listis a list of your variables thendf[col_list].apply(sm.tsa.stattools.adfuller, maxlag=None, autolag='BIC', regression='c')you can assign these to new columns and then transpose if you want the columns as index values.