Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How to Compute Industry Values?

Forgive the question of a struggling newbie, but I was wondering how you would go about sorting your universe into industries and then computing things like the PE and average returns using the stocks grouped into that industry: I have tried and failed miserably.

1 response

Take a look at the attached notebook. Some of the built in factors have a 'groupby' parameter. Otherwise you can run the pipeline and then use the pandas 'groupby' method to do your own grouping (see http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.groupby.html). This also works the same in algorithms. Good luck!