0

Dataframe I have Dataframe called "returns" that have time series (index) of returns for 10 sectors. How can I use for loops going through daily time series and find the name of sectors (column) that returns positive? I've tried this below, and was able to get positive returns, but what I need is the names of sectors.

for n in range(0,len(returns))
   pos_return = returns.iloc[n][returns.iloc[n]>0]

Here is what my data looks like.

enter image description here

1 Answer 1

1

you can use pos_return = returns.iloc[n][returns.iloc[n]>0].index which will return an Index object which can be cast to a list or whatever.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.