问题
I want to trasnform the following data frame:
ID 1234
type band category
0 A B C
to:
ID type band category
1234 A B C
where ID is the index column
回答1:
Try
df.stack(0).reset_index().drop('level_0', axis=1)
Output:
ID Type band category
0 1234 A B C
来源:https://stackoverflow.com/questions/62580244/data-frame-index-transformation-in-pandas