1dict_ = {
2'C':[1,2,3,4],
3'B':[2,4,5,8],
4'A':[7,5,7,8],
5'D':[1,7,8,7]
6}
7
8from pandas import DataFrame
9df = DataFrame(dict_)
10#unorder columns
11df
12 C B A D
130 1 2 7 1
141 2 4 5 7
152 3 5 7 8
163 4 8 8 7
17#only follow from this line when have existing dataframe.
18col = df.columns
19col = list(col)
20['C', 'B', 'A', 'D'] #unorder column
21
22col.sort()
23df = df[col]
24df
25#ordred columns.
26 A B C D
270 7 2 1 1
281 5 4 2 7
292 7 5 3 8
303 8 8 4 7
31