how to pivot dataframe without adding column and i

2019-03-04 11:35发布

pivot is a great function but results in a dataframe with a few extra info that I don't need: How can I achieve below? I do not need "bar" or "foo", and I want to make the df more concise. Thanks.

enter image description here

1条回答
Lonely孤独者°
2楼-- · 2019-03-04 12:29

Set index and columns names to None:

df.index.name = None
df.columns.name = None

Or use rename_axis:

df = df.rename_axis(None).df.rename_axis(None, axis=1)
查看更多
登录 后发表回答