python pandas data transform [duplicate]

  pandas, python

I can do this transformation using just pure python but I wonder if there a way to transform data in table below using some builtin pandas methods.

Source:
|region|param name|2010|2011|…|2020|
| —- | —- | —- | —- | —- | —- |
|England|population|111|112|…|133|
|France|population|111|112|…|133|
|Italy|population|111|112|…|133|
|England|earnings|111|112|…|133|
|France|earnings|111|112|…|133|
|Italy|earnings|111|112|…|133|

Target:
|region|param name|year|value|
| —- | —- | —- | —- |
|England|population|2010|111|
|England|population|2011|112|
|…|…|…|…|
|England|earnings|2010|112|

Thanks

Source: Python Questions

LEAVE A COMMENT