Hey Brian, I have a couple questions regarding rank in the example codes provided:
- I noticed rank doesn't "sort". For example
ranked_companies = roic.rank(axis=1,ascending=False, pct=True)
My thought was that a call to 'rank' here would show the top ranked companies by their ROIC, but when you print out the dataframe, whether by itself or with stack(), it looks like no operation has been performed because the columns are not arranged by highest ranked company (highest value). How would you get the top 30 ranked stocks off this operation?
- If you wanted to rank on multiple factors, how would you do it? For example in Magic Formula Investing, (Magic formula investing - Wikipedia), they want you to rank stocks by ROIC and Earnings Yield. My solution was to (ROIC + Earnings_Yield) / 2 to get a combined ranking factor, but is there a better way to do this with pandas?