题解 | #牛客网用户练习的平均次日留存率#

牛客网用户练习的平均次日留存率

https://www.nowcoder.com/practice/1f9e2b9be96b4b27a2476f8f12c5d29f

import pandas as pd 
df = pd.read_csv('nowcoder.csv',sep = ',')
df.date = pd.to_datetime(df.date).dt.date
df1 = df.copy()
df1.date = df.date + pd.Timedelta(days=1)
merge_df = pd.merge(df,df1,how='inner',on=['user_id','date'])
num = merge_df.user_id.count()
total = df.user_id.count()
print(round(num / total,2))

全部评论

相关推荐

点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务