I have the following 2 dataframes with the same structure (Same row names and column names) but different values:
DF1
| date | A | B | C | D |
|---|---|---|---|---|
| 2005-01-01 | 5 | 10 | 15 | 20 |
| 2005-01-02 | 1 | 2 | 3 | 4 |
| 2005-01-03 | 5 | 10 | 15 | 20 |
| 2005-01-04 | 5 | 10 | 15 | 20 |
| ... | ... | ... | ... | ... |
DF2
| date | A | B | C | D |
|---|---|---|---|---|
| 2005-01-01 | 0,1 | 0,2 | 0,3 | 0,4 |
| 2005-01-02 | 0,2 | 0,4 | 0,6 | 0,8 |
| 2005-01-03 | 0,3 | 0,6 | 0,9 | 1 |
| 2005-01-04 | 0,4 | 0,5 | 0,6 | 0,7 |
| ... | ... | ... | ... | ... |
My goal is to combine them as follows:
| date | Name | DF1_value | DF2_value |
|---|---|---|---|
| 2005-01-01 | A | 5 | 0,1 |
| 2005-01-01 | B | 10 | 0,2 |
| 2005-01-01 | C | 15 | 0,3 |
| 2005-01-01 | D | 20 | 0,4 |
| 2005-01-02 | A | 1 | 0,2 |
| 2005-01-02 | B | 2 | 0,4 |
| 2005-01-02 | C | 3 | 0,6 |
| 2005-01-02 | D | 4 | 0,8 |
| ... | ... | ... | ... |
I tried to use melt() function for each dataframe and then concatenate (concat()) them but it creates unnecessary rows for the column "Name".
Any help would be most appreciated!