I am trying to combine two datasets, but I cannot figure out which method is most suitable (join, merge, concat, etc.) for this application, and there are no examples in the documentation that do what I need to do.
I have two data sets structured like this:
>>> A
Time Voltage
1.0 5.1
2.0 5.5
3.0 5.3
4.0 5.4
5.0 5.0
>>> B
Time Current
-1.0 0.5
0.0 0.6
1.0 0.3
2.0 0.4
3.0 0.7
I would like to combine the data columns and combine the "Time" column together to get the following:
>>> AB
Time Voltage Current
-1.0 0.5
0.0 0.6
1.0 5.1 0.3
2.0 5.5 0.4
3.0 5.3 0.7
4.0 5.4
5.0 5.0
I tried AB = merge_ordered(A, B, on='Time', how='outer'), and while it successfully combined the data, it outputs something similar to:
>>> AB
Time Voltage Current
-1.0 0.5
0.0 0.6
1.0 5.1
1.0 0.3
2.0 5.5
2.0 0.4
3.0 5.3
3.0 0.7
4.0 5.4
5.0 5.0
You will notice that he did not join the lines with the common values of "Time".
I also tried to merge a la AB = A.merge(B, on='Time', how='outer'), but it outputs something combined, but not sorted, for example:
>>> AB
Time Voltage Current
-1.0 0.5
0.0 0.6
1.0 5.1
2.0 5.5
3.0 5.3 0.7
4.0 5.4
5.0 5.0
1.0 0.3
2.0 0.4
... "Current" , . .
AB = pandas.concat(A, B, axis=1), . , , DataFrames, :
>>> AB
Time Voltage Time Current
1.0 5.1 -1.0 0.5
2.0 5.5 0.0 0.6
3.0 5.3 1.0 0.3
4.0 5.4 2.0 0.4
5.0 5.0 3.0 0.7
, merge join, , , . , , " , /". - , ? Pandas!