python_两个数据集_关联_拼接&join操作&merge(数据集关联分析案例python)

网友投稿 413 2022-08-24


python_两个数据集_关联_拼接&join操作&merge(数据集关联分析案例python)

python_两个数据集拼接&join操作

t3 = dataset3[['user_id','coupon_id','date_received']]t3 = pd.merge(t3,t2,on=['user_id','coupon_id'],how='left')t3['this_month_user_receive_same_coupon_lastone'] = t3.max_date_received - t3.date_receivedt3['this_month_user_receive_same_coupon_firstone'] = t3.date_received - t3.min_date_received#根据多个字段就进行mergeother_feature3 = pd.merge(t1,t,on='user_id')other_feature3 = pd.merge(other_feature3,t3,on=['user_id','coupon_id'])other_feature3 = pd.merge(other_feature3,t4,on=['user_id','date_received'])other_feature3 = pd.merge(other_feature3,t5,on=['user_id','coupon_id','date_received'])other_feature3 = pd.merge(other_feature3,t7,on=['user_id','coupon_id','date_received'])other_feature3.to_csv('data/other_feature3.csv',index=None)#拼接数据集#两个数据框合并为一个df_train_stmt = pd.concat([df_train_stmt,df_train_stmt_test],axis = 0)


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:python_datafram两列拼接,中间加上特殊字符(python两个字段拼接)
下一篇:使用SpringBoot项目导入openfeign版本的问题
相关文章

 发表评论

暂时没有评论,来抢沙发吧~