本文介绍了 pandas :加入有条件的数据框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
所以我有这个数据框(如下所示),我试图通过将其复制到另一个 df 来加入自己.加盟条件如下;加盟条件:
So I have this dataframe (as below), I am trying to join itself by copying it into another df. The join condition as below; Join condition:
- PERSONID 和 Badge_ID 相同
- 但不同的 SITE_ID1
- 两行之间的时间差应小于 48 小时.
期待
这就是我累的地方,制作 df 的副本,然后使用下面的条件过滤每个 df,然后再次加入它们.但是以下条件不起作用:(在读入 df 之前,我在 SQL 中尝试了这个过滤器,但是对于 600k+ 行、带有索引的事件来说,这太慢了.
Here is what I tired, Make a copy of df and then filter each df with this condition like below and then join them back again. But the below condition doesn't work :( I tried this filters in SQL before reading into df but that's too slow for 600k+ rows, event with indexes.
推荐答案
试试以下:
这篇关于 pandas :加入有条件的数据框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!