0

I have a dataframe, which I am trying to transform into a desired format.

The current dataframe looks like the below:

+----------+--------+--------+--------+--------+--------+--------+--------+
| year     | 1991   | 1992   | 1992   | 1993   | 1993   | 1994   | 1995   |
+----------+--------+--------+--------+--------+--------+--------+--------+
| location | london | london | berlin | london | berlin | london | london |
+----------+--------+--------+--------+--------+--------+--------+--------+
| revenue  | 100    | 150    | 100    | 200    | 150    | 250    | 300    |
+----------+--------+--------+--------+--------+--------+--------+--------+

I'd like to transform into a matrix which shows the revenue based on location / year:

+------+--------+--------+
|      | london | berlin |
+------+--------+--------+
| 1991 | 100    |        |
+------+--------+--------+
| 1992 | 150    | 100    |
+------+--------+--------+
| 1993 | 200    | 150    |
+------+--------+--------+
| 1994 | 250    |        |
+------+--------+--------+
| 1995 | 300    |        |
+------+--------+--------+

0 Answers0