python sort dataframe by list

Solutions on MaxInterview for python sort dataframe by list by the best coders in the world

showing results for - "python sort dataframe by list"
Mario
16 Apr 2018
1# sorts the dataframe so resulting order of ColumnName matches order in list
2df = df.set_index(ColumnName).reindex(list_to_sort_by).reset_index()