pandas merging based on a timestamp which do not match exactly

后端 未结 3 734
礼貌的吻别
礼貌的吻别 2020-11-30 04:12

What methods are available to merge columns which have timestamps that do not exactly match?

DF1:

date    start_time  employee_id session_id
01/01/20         


        
3条回答
  •  庸人自扰
    2020-11-30 04:58

    I would suggest to use the built-in pandas Series dt round function, to round both dataframe to a common time, for example round up to every 5min. So the time will always be in format: 01:00:00 and then 01:05:00 for example. In that way, both dataframe will have similar time index to perform the merge.

    Please see documentation and examples here pandas.Series.dt.round

提交回复
热议问题