Data frame index transformation in Pandas(Pandas中的数据帧索引转换)
问题描述
我想转换以下数据框:
ID 1234
type band category
0 A B C
收件人:
ID type band category
1234 A B C
其中ID是索引列
推荐答案
尝试
df.stack(0).reset_index().drop('level_0', axis=1)
输出:
ID Type band category
0 1234 A B C
这篇关于Pandas中的数据帧索引转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!