【发布时间】:2020-10-16 04:47:32
【问题描述】:
我要转换以下数据框:
ID 1234
type band category
0 A B C
到:
ID type band category
1234 A B C
其中 ID 是索引列
【问题讨论】:
标签: python-3.x pandas reshape reindex
我要转换以下数据框:
ID 1234
type band category
0 A B C
到:
ID type band category
1234 A B C
其中 ID 是索引列
【问题讨论】:
标签: python-3.x pandas reshape reindex
试试
df.stack(0).reset_index().drop('level_0', axis=1)
输出:
ID Type band category
0 1234 A B C
【讨论】: