I follow this thread which doesn't fully answer my solution : Best way to join / merge by range in pandas
I precise that my min/max in my case are DateTime but this works without any problem.
The accepted answer works fine for me, however I think this could be optimized for my use case.
Indeed, it will create a mega datframe which concatenates both A and B df, whereas I would need only the rows where A_id and B_id match exactly.
My original df has 79k rows. After processing this
C = pd.DataFrame(
np.column_stack([A.values[i], B.values[j]]),
columns=A.columns.append(B.columns)
)
I have a df of 2.3 m rows, which when I keep only C[C['A_id'] == C['B_id']]
goes back to 74k rows which is what I expect.
How can I do it directly in the first operation, improving at the same time the time to process ?
Thanks