【发布时间】:2021-01-07 09:59:26
【问题描述】:
我是 Python 和编程方面的菜鸟,这就是为什么,如果我在描述我的请求时有错误,请不要评判我。所以我需要解决一个任务。
我有两个 DateFrame。其中之一有 20 000 行和三列:id_clients、start_time_visit、end_time_visit。 DateFrame 的名称 = 访问次数 这是用户对网站的访问。
Second DateFreme 有 800 行,并且有列:id_lead、time_create_lead、model。 此数据来自 CRM 系统。
所以我需要找出来自网站的哪些 id_clients 在 CRM 中创建了潜在客户。
我认为我可以从周期申请,例如:start_time
我已经写了这段代码:
dict_time = crm.set_index('time_create_lead').to_dict() # create a dict
def time_search (row):
""" This function has to return a row with create_time_of_lead"""
time_start = row['start_time']
time_end = row['end_time']
if time_start <= dict_time <= time_end:
return value
else:
return 0
goals['leed'] = goals.apply(time_search, axis=1)
但我有这个错误:TypeError: '<=' not supported between instances of 'Timestamp' and 'dict'
我研究了互联网,但没有找到解决这个问题的方法。我将不胜感激。
【问题讨论】:
标签: python pandas dataframe datetime cycle