Home > Mobile >  Resampling 2 time series
Resampling 2 time series

Time:08-17

I have 2 time series which each have a record every 30 seconds with a difference of about 21 seconds ;

ts1 starts at 12:30:00 And the second record at 12:30:30

ts2 starts at 12:30:21 And the second record at 12:30:51

What is the best way to merge them without losing information I want to have the same index for both

CodePudding user response:

IIUC use merge_asof:

df = pd.merge_asof(ser1.to_frame('a'), 
                   ser2.to_frame('b'), 
                   left_index=True, 
                   right_index=True)

CodePudding user response:

You can have two separate columns for ts1 and ts2, use pd.concat() which with a default 'outer' join method, and resample with ffill(), if necessary.

  • Related