For post-processing of some measurements i have three pandas dataframes that look like this:
df1:
direction sequence timestamp remote_timestamp delta
0 U 1 461945 -1 -1
1 U 2 462106 -1 -1
2 U 3 462269 -1 -1
.. ... ... ... ... ...
97 U 98 477601 -1 -1
98 U 99 477762 -1 -1
99 U 100 477924 -1 -1
df2:
direction sequence timestamp remote_timestamp delta
0 U 101 500663 -1 -1
1 U 102 500829 -1 -1
2 U 103 501000 -1 -1
.. ... ... ... ... ...
98 U 199 516631 -1 -1
99 U 200 516792 -1 -1
df3
direction sequence timestamp remote_timestamp delta
0 U 1 -1 462791 -1
1 U 2 -1 462791 -1
2 U 3 -1 462894 -1
.. ... ... ... ... ... ...
197 U 198 -1 525099 -1
198 U 199 -1 525100 -1
199 U 200 -1 525100 -1
So i have two dataframes that have 100 lines and one that has 200 lines. Now i want to write the column "remote_timestamp" of the third dataframe into the first and second at the positions of their sequence number.
For either one of the frames I tried somethng like this:
df1['remote_timestamp'] = numpy.where(df1['sequence'].values == df3['sequence'].values,df3['remote_timestamp'],-1)
but since the lengths of the dataframes do not match i get:
ValueError: Length of values does not match length of index
What would be a way to solve the problem. Maybe numpy.where
is not the ideal solution.
Thank you