import pandas as pd
file_path=""
df=pd.read_csv(file_path,sep=',',header=None)
#列转行
pf=df.pivot_table(index=0,columns=1,values=2)
cols=list(pf)
cols.insert(0,cols.pop(cols.index('nu'))) #调整列索引的顺序
pf=pf.loc[:,cols]
#调整行索引的顺序
pf=pf.reindex(['nu','0','1_5','6_15','16_30','31'])
#写入csv文件
write_file = ""
pf.to_csv(write_file,sep=',',header=True,index=True)