0 votes
1 view
in Python by (47.8k points)

I have a dataframe with over 200 columns. The issue is as they were generated the order is


I need to re-order the columns as follows:


Is there some way for me to do this within Python?

1 Answer

0 votes
by (107k points)

For Re-ordering columns in pandas dataframe based on a column name you can use the below-mentioned piece of code:-

df = df.reindex(sorted(df.columns), axis=1)

Welcome to Intellipaat Community. Get your technical queries answered by top developers !