For example, we have data on cities and the population in them in different years.
City | 2000 | 2005 | 2010 | 2015 |
---|---|---|---|---|
City_1 | 10 | 11 | 12 | 13 |
City_2 | 15 | 14 | 13 | 12 |
City_3 | 20 | 30 | 25 | 35 |
I need to get the DataFrame in this form:
City | Year | Population |
---|---|---|
City_1 | 2000 | 10 |
City_1 | 2005 | 11 |
City_1 | 2010 | 12 |
City_1 | 2015 | 13 |
City_2 | 2000 | 15 |
City_2 | 2005 | 14 |
City_2 | 2010 | 13 |
City_2 | 2015 | 12 |
City_3 | 2000 | 20 |
City_3 | 2005 | 30 |
City_3 | 2010 | 25 |
City_3 | 2015 | 35 |
How can this be done using Python?