python购物实例分析

这篇文章主要介绍“python购物实例分析”,在日常操作中,相信很多人在python购物实例分析问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”python购物实例分析”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

成都创新互联公司专业为企业提供赤坎网站建设、赤坎做网站、赤坎网站设计、赤坎网站制作等企业网站建设、网页设计与制作、赤坎企业网站模板建站服务,十余年赤坎做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

任务: 合生元品牌的奶粉会员的营养品子品和其他大类的购物篮分析

思路:

合生元奶粉流水与营养品二级品类流水 依据流水号left  join, 再与其他大类流水left join,且大类的类别名称要更改

获得合生元奶粉(品类cls)和 营养品二级品类(品类cls2)流水,并left join

zhenjia= saleflow.item_name.str.contains('奶粉')|saleflow.item_brandname.str.contains('奶粉')|saleflow.cls.str.contains('奶粉')|saleflow.cls2.str.contains('奶粉')&saleflow.c1.str.contains('奶粉')&saleflow.c2.str.contains('奶粉')|saleflow.c3.str.contains('奶粉')
naifen_saleflow=saleflow[zhenjia]naifen_saleflow['品牌'] =  naifen_saleflow.apply(pinpai_class_pro,axis=1) # 这些函数只能针对奶粉数据naifen_vipflow =naifen_saleflow[(naifen_saleflow['card_id']!=np.nan) & (naifen_saleflow['custype']=='vip')&(naifen_saleflow['sale_money']>0)]yyp_saleflow= saleflow[saleflow['cls']=='营养品']#saleflow_naifen_hsy =  saleflow_naifen[saleflow_naifen['品牌']=='合生元'] YYP =yyp_saleflow[[ 'branch_no','card_id','flow_no','cls2', 'shopid_cardid','age']]saleflow_heshengyuan_naifen = naifen_saleflow[naifen_saleflow['品牌']=='合生元']HSY_NAIFEN=saleflow_heshengyuan_naifen[[ 'shopId','branch_no', 'card_id','flow_no', 'cls', 'shopid_cardid']]

合生元奶粉和营养品左连接

HSY_NAIFEN_YSJ = HSY_NAIFEN.merge(YYP, how='left')

再获得各大类(cls 中的用品、玩具、辅食等)的流水,并且各大类的里面要重命名,比如 用品的 cls 列名要重命名为 cls_yongpin,  依次类推

yongpin_saleflow= saleflow[saleflow['cls']=='用品']YONGPING =yongpin_saleflow[[ 'branch_no','card_id','flow_no','cls', 'shopid_cardid','age']].\rename(columns={'cls':'cls_yongpin'})
zhipin_saleflow= saleflow[saleflow['cls']=='纸品']ZHIPIN =zhipin_saleflow[[ 'branch_no','card_id','flow_no','cls', 'shopid_cardid','age']].\rename(columns={'cls':'cls_zhipin'})
wanju_saleflow= saleflow[saleflow['cls']=='玩具']WANJU =wanju_saleflow[[ 'branch_no','card_id','flow_no','cls', 'shopid_cardid','age']].\rename(columns={'cls':'cls_wanju'})
mianpin_saleflow= saleflow[saleflow['cls']=='棉品']MIANPIN  = mianpin_saleflow[[ 'branch_no','card_id','flow_no','cls', 'shopid_cardid','age']].\rename(columns={'cls':'cls_mianpin'})
fushi_saleflow= saleflow[saleflow['cls']=='辅食']FUSHI  = fushi_saleflow[[ 'branch_no','card_id','flow_no','cls', 'shopid_cardid','age']].\rename(columns={'cls':'cls_fushi'})
fuwu_saleflow= saleflow[saleflow['cls']=='服务']FUWU  = fuwu_saleflow[[ 'branch_no','card_id','flow_no','cls', 'shopid_cardid','age']].\rename(columns={'cls':'cls_fuwu'})
chechuang_saleflow= saleflow[saleflow['cls']=='车床']CHECHUANG  = fushi_saleflow[[ 'branch_no','card_id','flow_no','cls', 'shopid_cardid','age']].\rename(columns={'cls':'cls_chechuang'})

最后合并

RESUT =(((((HSY_NAIFEN_YSJ.merge(YONGPIN,how='left')).merge(ZHIPIN,how='left'))\  .merge(MIANPIN,how='left')).merge(FUSHI,how='left')).merge(FUWU,how='left')).\merge(CHECHUANG,how='left').merge(WANJU,how='left')

连接各类别字符串,得到订单购物篮

RESULT =RESUT.replace(np.nan,'')RESULT['订单购物篮']= RESULT['cls']+'-'+RESULT['cls2']+'-'+RESULT['cls_zhipin'] + \'-'+ RESULT['cls_fuwu'] + '-'+ RESULT['cls_mianpin']+'-'+\RESULT['cls_chechuang']+'-'+RESULT['cls_yongpin']+'-'+ RESULT['cls_wanju'] +'-'+ RESULT['cls_fushi']

python购物实例分析

到此,关于“python购物实例分析”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!


文章名称:python购物实例分析
网页链接:http://scjbc.cn/article/gshpcg.html

其他资讯