I'm trying to create a Pandas dataframe that is created of multiple smaller dataframes. All dataframes got the same Index variable but sometimes have different coloums, wich should be added if non existent.
So basically a join (outer i guess) would be the right thing. But instead of creating a new column in case of an overlap it should be pushed in the column with the original name.
To give a small example:
A: B: C:
Time col1 col2 Time col1 col2 Time col3 col4
0 1 2 0.2 2 1 0.1 1 5
0.1 3 4 0.3 1 2 0.2 7 4
Should be combined to:
Time col1 col2 col3 col4
0 1 2 1 5
0.1 3 4 7 4
0.2 2 1 NaN NaN
0.3 1 2 NaN NaN
I searched for an elegant solution to this but all i came up with is iterating over every cell of the dataframe. Is there any better possibility?