I have a Python app that gets speed data changes from devices for one day and graphs them using matplotlib. I currently store that data in dictionary like this:
port_1_info = {datetime.datetime(2022, 12, 4, 4, 27, 24): 158,
datetime.datetime(2022, 12, 4, 4, 27, 25): 44,
datetime.datetime(2022, 12, 4, 4, 27, 32): 90,
datetime.datetime(2022, 12, 4, 4, 27, 37): 158,
datetime.datetime(2022, 12, 4, 4, 27, 41): 181, ...}
port_2_info = { ... } # same format different times
I have two sets of data in this format: one for port 1 and the other for port 2. I would like to combine them into one set of data that is the sum of speeds throughout the day. One issue is that the time intervals are different, because the speed changes happen randomly.
How would I go about merging them? I have already sorted each dictionary but am struggling to find a way to sum them properly.
I tried using a third dictionary and input all data into it but can't find an algorithm that will make it work properly