我有一个看起来像的数据框,
JAPE_feature
100 200 2200 2600 4600
did offset word
0 0 aa 0 1 0 0 0
0 11 bf 0 1 0 0 0
0 12 vf 0 1 0 0 0
0 13 rw 1 0 0 0 0
0 14 asd 1 0 0 0 0
0 16 dsdd 0 0 1 0 0
0 18 wd 0 0 0 1 0
0 20 wsw 0 0 0 1 0
0 21 sd 0 0 0 0 1
现在,在这里,我尝试将数据框保存为csv格式。
df.to_csv('data.csv')
SO,它的存储方式就像
现在,在这里我试图保存而不在JAPE_feature列中创建新列。它只会在一列中包含5个子功能。
JAPE_FEATURES
100 | 200 | 2200 | 2600 | 4600
the sub-columns should be like this . It should not create the different columns
答案 0 :(得分:1)
我认为最好是将DataFrame转换为excel,如果需要merge
的第一级{1>}:
MultiIndex in columns
如果要df.to_excel('data.xlsx')
就是问题,有必要将csv
更改为将重复的值替换为空字符串:
MultiIndex