how to pivot dataframe without adding column and index name

前端 未结 1 1902
遇见更好的自我
遇见更好的自我 2021-01-26 00:16

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

1条回答
  •  醉梦人生
    2021-01-26 00:55

    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)
    

    0 讨论(0)
提交回复
热议问题