I have three different time based dataframes with 10s of thousands of data points.
df1['time'] = 1, 2, 3, 4, 5
df1['data1'] = 1, 0, 0, 1, 0
df2['time'] = 1, 3, 5, 7, 9
df2['data2'] = a, b, c, d, e
df3['time'] = 3, 4, 5, 6, 7
df3['data3'] = z, y, x, w, v
I want to combine these dataframes into 1 dataframe only where they have the same time point existing. In the above dataframes only time 3 and 5 exist concurrently across all three so merge those data points into the final dataframe.
df4['time'] = 3, 5
df4['data1'] = 0, 0
df4['data2'] = b, c
df4['data3'] = z, x
I've been trying to avoid iterating over the dataframes with if statements because of the numerous data points and the answer in How to iterate over rows in a DataFrame in Pandas from cs95 basically saying to avoid iterating if possible.
Am I stuck iterating through the dataframes or is there vectorization/list comprehension method I can follow?