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.

Loading notebook preview...