'Python Pandas Column Formation

Is there an easy way to reformat the columns from

2000-01-03 Location1 A1 B1 C1 A2 B2 C2 A3 B3 C3  
2000-01-04 Location2 A1 B1 C1 A2 B2 C2 A3 B3 C3  
2000-01-05 Location3 A1 B1 C1 A2 B2 C2 A3 B3 C3

to

2000-01-03 Location1 A1 A2 A3 B1 B2 B3 C1 C2 C3  
2000-01-04 Location2 A1 A2 A3 B1 B2 B3 C1 C2 C3  
2000-01-05 Location3 A1 A2 A3 B1 B2 B3 C1 C2 C3 

Thanks



Solution 1:[1]

One of the easiest ways to reorder the columns of Pandas DataFrame is to use indexing

reordered_col_list = ['Date', 'Location', 'A1', 'A2', 'A3', 'B1', 'B2', 'B3', 'C1', 'C2', 'C3']
df = df[reordered_col_list]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Aditya