【发布时间】:2022-01-21 05:53:00
【问题描述】:
我有一个如下所示的 DataFrame:
region 2008_indicatorA 2008_indicatorB ...(2009..2019)... 2020_indicatorA 2020_indicatorB
=============================================================================================
State1 ... ... ... ...
State2 ... ... ... ...
...
我需要从列中提取年份并创建一个单独的列year,同时减少列数。生成的 DF 应如下所示:
region year indicatorA indicatorB
========================================
State1 2008 ... ...
State1 2009 ... ...
...
State1 (..2020) ... ...
...
State2 2008 ... ...
...
【问题讨论】:
标签: python pandas reshape multi-index