Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python sort dataframe by list

# sorts the dataframe so resulting order of ColumnName matches order in list
df = df.set_index(ColumnName).reindex(list_to_sort_by).reset_index()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Python #sort #dataframe #list
ADD COMMENT
Topic
Name
9+9 =