根据条件组合熊猫数据框?

时间:2019-06-28 12:18:01

标签: python pandas dataframe merge append

嗨,我有两个数据帧,分别如下所示:df_com和df_tra

Event Type  Event Type  ID  Time_Comptel    Distance_Comptel    Fibre Line  Event Date  Event Date
0   Digging Manual Digging  11988339    2019-06-26 12:27:44 444.83  Helios 1012, Channel 2  2019-06-26  2019-06-28
1   Digging Manual Digging  11988337    2019-06-26 12:22:10 447.55  Helios 1012, Channel 2  2019-06-26  2019-06-28
2   Digging Manual Digging  11988336    2019-06-26 12:26:50 446.19  Helios 1012, Channel 2  2019-06-26  2019-06-28
3   Digging Manual Digging  11988335    2019-06-26 12:22:13 447.55  Helios 1012, Channel 2  2019-06-26  2019-06-28
4   Digging Manual Digging  11988334    2019-06-26 12:10:05 446.87  Helios 1012, Channel 2  2019-06-26  2019-06-28


Alarm ID    Event Type  Event Type  Event Date  Event Date  Position    Distance_Tranzmeo   Event Channel   Event Time  Time_Tranzmeo
0   454.0   Digging Manual Digging  2019-06-26  2019-06-28  43.0    0.293   1.0 06:09 am    2019-06-28 06:09:00
1   455.0   Digging Manual Digging  2019-06-26  2019-06-28  2585.0  17.594  1.0 06:09 am    2019-06-28 06:09:00
2   456.0   Digging Manual Digging  2019-06-26  2019-06-28  2585.0  17.594  1.0 06:50 am    2019-06-28 06:50:00
3   457.0   Digging Manual Digging  2019-06-26  2019-06-28  45.0    0.306   1.0 07:04 am    2019-06-28 07:04:00
4   458.0   Digging Manual Digging  2019-06-26  2019-06-28  44.0    0.299   1.0 07:26 am    2019-06-28 07:26:00

我喜欢创建另一个数据框,使得Time_Comptel应该接近Time_Tranzmeo(任何行,不必分别是行)(接近意味着它们之间的最大差应为+或-1小时并且Distance_ComptelDistance_tranzmeo也应关闭(+或-100)。

逐行加入此类行,并将其附加到一个数据帧(df_match)上,然后放置到另一个datafame(df_nomatch)上。这怎么可能?抱歉,我自己还无法提出想法来检查我得到的各个行,但是我需要比较每个组合。如何完成。

Note: Time_Tranzmeo is the last column in dataframe 2

如果我对某事没有重视,请在评论中让我知道

0 个答案:

没有答案