Skip to content
Advertisement

Python Pandas Column Formation

Is there an easy way to reformat the columns from

JavaScript

to

JavaScript

Thanks

Advertisement

Answer

To reorder columns dynamically based on value, here is a way to do it:

JavaScript

This returns a dataframe with columns (axis=1) ordered based on sorted value of first row.

Here is a full example using your data sample:

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement