I have a dataframe containing several columns labelled x1, x2, x3, and x4.
Depending on the analysis, I would need to assign one of the four columns to be the first column when ordering the four columns in the dataframe from left-to-right.
For instance, if I want column 'x2' to be the first I assign it to 'sorter'.
sorter = x2
Now my question: how I sort the dataframes in the column so that the column assigned to 'sorter' is located in the first column?
EDIT: The order of the rest of the columns should remain unchanged.
df.sort_values(['x2','x1','x3','x4'])?