Dataframe 1 is a empty dataframe intended to set the "headers" of the columns:
| Header Green | Header Yellow | Header Red |
|---|
Dataframe 2 holds the actual rows, but some of the columns might be different from dataframe 1.
| Header Green | Header Yellow | Header Purple |
|---|---|---|
| Data Green | Data Yellow | Data Purple |
In the resulting dataframe, I want to stack the two dataframes on top of each other, but only keeping the columnes that are in dataframe1 (that is Green,Yellow,Red). The final dataframe should then be:
| Header Green | Header Yellow | Header Red |
|---|---|---|
| Data Green | Data Yellow | Blank |
Just to be clear, the final table:
1 Keeps all the columns from dataframe 1
2 Add the data from dataframe 2 where the columns are the same as dataframe 1
3 Drops any column from dataframe 2 that is not in datafram 1 in the final dataframe.
Unfortunately there is a lot of columns in the dataframes, so the solution needs to understand which columns to keep without being given anything else then the existing name in the dataframes.
Thanks!