【发布时间】:2021-10-04 08:07:38
【问题描述】:
我正在尝试计算客户上次访问时间与客户最近访问时间之间的时间差(以天为单位)。
time difference = latest in time - previous out time
这是输入数据的示例
样本输出表
目前我尝试过的基于客户 ID 和排名的 groupby 方法
temp['RANK'] = temp.groupby('customer ID')['in time'].rank(ascending=True)
但我不确定如何计算差异。
【问题讨论】:
-
Please don't post images of code/data (or links to them)。如何从样本数据中计数
21 days?
标签: python pandas dataframe pandas-groupby sklearn-pandas