0

I have a dataframe which looks as the following:

2017       2018       2019        2020        departement        author

value_1    value_2    value_3     value_4     departement_1      author_1
value_5    value_6    value_7     value_8     departement_2      author_2

I want to merge the columns (2017, 2018, 2019, and 2020) into one column (year) and in the same time create a new column (amount) with the values corresponding to each year; so the resulting dataframe should look like the following:

year    amount    author     departement
2017    value_1   author_1   departement_1
2018    value_2   author_1   departement_1
2019    value_3   author_1   departement_1
2020    value_4   author_1   departement_1
2017    value_5   author_2   departement_2
2018    value_6   author_2   departement_2
2019    value_7   author_2   departement_2
2020    value_8   author_2   departement_2

Could anyone help me solving this problem? Thanks in advance.

Aniss Chohra
  • 391
  • 4
  • 18

0 Answers0