python change column order in dataframe

df = df.reindex(columns=column_names)

Here is what the above code is Doing:
1. We’re creating a list of column names that we want to use.
2. We’re using the reindex() method to rearrange the columns in the DataFrame.
3. We’re passing in the list of column names that we created in step 1.