Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (47.6k 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 (106k 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!

29.3k questions

30.6k answers


104k users

Browse Categories