【问题标题】:How do I unpivot this multiple header and variable data table?如何取消透视这个多标题和可变数据表?
【发布时间】:2020-02-05 21:33:40
【问题描述】:

我在 excel 中有一个实验室报告,其中包含多个级别的标题和多个变量,

enter image description here

我想将它还原到一张带有 pandas 的平面表中,格式如下图所示,有人可以帮忙吗?

enter image description here

【问题讨论】:

  • 不要使用图像,而是添加创建输入数据帧示例的代码。 See this post

标签: python-3.x pandas


【解决方案1】:

您可以将其读入数据框中,在此答案中查看具体内容: reading excel sheet as multiindex dataframe through pd.read_excel()

然后将您的数据框与df.stack() 堆叠在一起。

【讨论】:

    猜你喜欢
    • 2022-12-28
    • 2016-07-06
    • 2020-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-04
    相关资源
    最近更新 更多