Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Group Pipeline by equity name

Once I have created a Pipeline in a research notebook, is there a way to group by the equity name, instead of by the date? I would like to have a sequence of company-date values, rather than having a sequence of dates.

In other word I would rearrange the pandas dataframe by the 2nd level index.

1 response

One straightforward way is to use the swaplevel method. Something like this.

results = run_pipeline(pipe, start_date, end_date)  
results_by_equity = results.swaplevel()

See attached notebook. Good luck.