0

I am stuck in the understanding of .iteritems(). I checked documents and code examples but that does not explain this specific case.

returns

Returns

from statsmodels.tsa.stattools import adfuller
pd.Series([adfuller(values)[1] < 0.05 for columns, values in returns.iteritems()], index = returns.columns)

It is showing,

result

I thought it is iterating rows, So I thoguth it would give me boolean per each row. However, it only gives me one boolean value per each index.

Would you please help me to understand why it works this way?

Ch3steR
  • 20,090
  • 4
  • 28
  • 58
Juh
  • 9
  • 2
  • [docs](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.iteritems.html) explicitly say it will iterate columns. Just use `returns.T.iteritems()` instead – Marat May 12 '20 at 15:08
  • Thanks @Marat. Does it mean if you want to get True, all values of each columns should be satisfied with adfuller(values)[1] < 0.05 ? – Juh May 12 '20 at 15:11
  • You will get a series where each cell corresponds to the result of `adfuller(row_values)[1] < 0.05`. I'm not familiar with internals of DF test to interpret the results. Also, note that `columns` in `for columns, values` is a bit misleading. `columns` will contain row label – Marat May 12 '20 at 15:14
  • I recommend checking out cs95's answer to this post: https://stackoverflow.com/questions/16476924/how-to-iterate-over-rows-in-a-dataframe-in-pandas/ – bug_spray May 12 '20 at 16:21

0 Answers0