I am trying to perform an outer join (union) of two time series in python. The left time series is larger than the first.
An example:
Right time series - df_1
Time | Series 1 |
---|---|
3 | 1 |
4 | 2 |
5 | 3 |
Left time series - df_2
Time | Series 2 |
---|---|
0 | 10 |
1 | 11 |
2 | 12 |
3 | 13 |
4 | 14 |
5 | 15 |
6 | 16 |
I simply tried:
pd.merge([df_1, df_2], how = "outer", on = "Time")
I expected to get something like this:
Time | Series 1 | Series 2 |
---|---|---|
0 | nan | 10 |
1 | nan | 11 |
2 | nan | 12 |
3 | 1 | 13 |
4 | 2 | 14 |
5 | 3 | 15 |
6 | nan | 16 |
Instead I got this:
Time | Series 1 | Series 2 |
---|---|---|
3 | 1 | 13 |
4 | 2 | 14 |
5 | 3 | 15 |
6 | nan | 16 |
It is crucial for the exercise to keep the time series in the correct sequence, I do not want to switch the order of the merge.