0

I am wondering if there is a way to rearrange the order of rows in my data frame the following way. Currently, my multi-index data frame looks like this: current order of rows in data frame

However, I would like to change the order to this: preferred order of rows in data frame

Is there any way how I could change the order efficiently so it is applied to the entire dat frame?

  • `df.sort_values(['gameId', 'playId', 'nflId', 'frameId'])` should be all you need. Maybe with an `inplace=True` – maow Jul 29 '21 at 15:20
  • Does this answer your question? [Reorder levels of MultiIndex in a pandas DataFrame](https://stackoverflow.com/questions/34029608/reorder-levels-of-multiindex-in-a-pandas-dataframe) – Acccumulation Jul 29 '21 at 15:21

0 Answers0