我目前的数据框列的顺序为
df.columns = ['S1FF', 'S1Ipmax', 'S2POA',
...
'M04Vpmax', 'M04elec_event', 'M04group', 'M04met_event', 'M04mode',
'M04validation_1min', 'M04validation_2min', 'M04S1T', 'M04S2T',
'M04datetime'] # Columns start with S1,S2, M01 to M24
我想以相反的字母顺序对它们进行排序。我现在的代码是
df = df.reindex(sorted(df.columns), axis=1)
我现在的输出是
df.columns = ['M01FF', 'M01Ipmax', 'M02POA',
...
'S1FF', 'S1Ipmax', 'S2POA']
但我的预期输出是反向字母顺序
df.columns = ['S1FF', 'S1Ipmax', 'S2POA','M01FF', 'M01Ipmax', 'M02POA',
...
'M23FF', 'M24Ipmax', 'M24POA']
慕标5832272
相关分类