如何将多级索引行转换为多级索引列?

时间:2020-08-04 19:22:08

标签: python-3.x pandas

如所附图片所示,我想转换数据帧的排列方式。

我尝试过:

index = pd.MultiIndex.from_product([df.index, df.columns])
new_df = pd.DataFrame(df.values.reshape(index.shape), index=index, columns=['value'])

但是出现错误消息:“未为MultiIndex定义isna”?

该如何解决?

感谢您的帮助。 enter image description here

0 个答案:

没有答案
相关问题