小编lif*_*cer的帖子

根据列名称在 pandas 数据框中堆叠

我有以下熊猫数据框:

 ID   Year  Jan_salary  Jan_days  Feb_salary Feb_days Mar_salary Mar_days
  1   2016     4500        22         4200      18        4700       24
  2   2016     3800        23         3600      19        4400       23
  3   2016     5500        21         5200      17        5300       23
Run Code Online (Sandbox Code Playgroud)

我想将此数据框转换为以下数据框:

ID     Year     month   salary   days
 1      2016      01     4500     22
 1      2016      02     4200     18
 1      2016      03     4700     24
 2      2016      01     3800     23
 2      2016      02     3600     19
 2      2016      03     4400     23
 3      2016      01     5500     21
 3      2016      02     5200     17
 3 …
Run Code Online (Sandbox Code Playgroud)

reshape dataframe python-2.7 pandas

4
推荐指数
1
解决办法
683
查看次数

标签 统计

dataframe ×1

pandas ×1

python-2.7 ×1

reshape ×1