如何按特定日期条件合并2个数据帧的列?

2024-09-30 19:27:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我有2个数据帧。其中一个具有[2262 rows x 6 columns]并且具有以下特性structure:- 数据帧名称是df_sat-

Date.       Col1.   Col2.......   Col6
2017-08-26  numeric values in these columns
2017-08-31
....
2018-10-30
2018-11-09

另一个数据帧的时间戳间隔为10分钟,形状为[30000x105],结构如下

DateTime.   Col1.  Col2.......... Col105
2017-08-26 00:00:00.  numeric values in these columns
2017-08-31 00:10:00
...
2018-11-01 15:50:00

我想将这两个数据帧根据它们共享的日期合并在一起,如果两个数据帧中没有相同的日期(因为dfëu sat的间隔不太规则),则可以考虑合并前一个日期

预期输出为

DateTime.   Col1.  Col2.......... Col105               Col1-6 from df_sat
2017-08-27 00:00:00.  numeric values in these columns   Use 2017-08-26
2017-08-27 00:10:00                                     Use 2017-08-26
...
2018-10-31 15:50:00                                     Use 2018-10-30

Tags: columns数据indfdatetime间隔usesat