在数据透视表之后如何在多索引中重塑数据框

时间:2019-12-17 15:11:56

标签: python pandas

我在这个主题“ pivot_table之后重塑数据框”时发现了一些类似的问题。我也遵循了这些方法(先运行droplevel然后运行“ reset_index”)。

在“ reset_index”步骤中出现错误时。 ( TypeError:无法将项目插入尚不存在的类别CategoricalIndex中

如何重塑此数据框?谢谢。

PS:我想保留index_name和那些多列名称。

enter image description here

0 个答案:

没有答案