In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "python Shopping case Analysis". In daily operation, I believe many people have doubts about python Shopping case Analysis. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts of "python Shopping case Analysis". Next, please follow the editor to study!
Task: Hesheng brand milk powder members' nutrition products and other major categories of shopping basket analysis
Train of thought:
Hesheng milk powder and nutrition secondary category according to the serial number left join, and then left join with other major categories, and the category names of the major categories should be changed.
The running water of Hesheng milk powder (category cls) and nutrition category II (category cls2) were obtained, and left join
Zhenjia= saleflow.item_name.str.contains ('milk powder') | saleflow.item_brandname.str.contains ('milk powder') | saleflow.cls.str.contains ('milk powder') | saleflow.cls2.str.contains ('milk powder') & saleflow.c1.str.contains ('milk powder') & saleflow.c2.str.contains ('milk powder') | saleflow.c3.str.contains ('milk powder')
Naifen_saleflow= Saleflow [Zhenjia] naifen_saleflow ['Brand'] = naifen_saleflow.apply (pinpai_class_pro Axis=1) # these functions can only be used for milk powder data naifen_vipflow = naifen_saleflow [(naifen_saleflow ['card_id']! = np.nan) & (naifen_saleflow [' custype'] = = 'vip') & (naifen_saleflow [' sale_money'] > 0)] yyp_saleflow= saleflow [saleflow ['cls'] = =' nutrition'] # saleflow_naifen_hsy = saleflow_ Naifen [saleflow _ naifen ['brand'] = 'symbiotic'] YYP = yyp_saleflow [['branch_no'' 'card_id','flow_no','cls2',' shopid_cardid','age']] saleflow_heshengyuan_naifen = naifen_ Saleflow [naifen _ saleflow ['brand'] = 'Hesheng'] HSY_NAIFEN=saleflow_heshengyuan_naifen [['shopId','branch_no',' card_id','flow_no','cls', 'shopid_cardid']]
Hesheng milk powder and nutrition are connected to the left.
HSY_NAIFEN_YSJ = HSY_NAIFEN.merge (YYP, how='left')
Then get the running water of all the major categories (cls supplies, toys, supplementary foods, etc.), and rename each category, for example, the cls column name of the products should be renamed to cls_yongpin, and so on.
Yongpin_saleflow= saleflow [saleflow ['cls'] =' supplies'] YONGPING = yongpin_saleflow [['branch_no','card_id','flow_no','cls',' shopid_cardid','age']].\ rename (columns= {'cls':'cls_yongpin'})
Zhipin_saleflow= saleflow [saleflow ['cls'] = =' Paper'] ZHIPIN = zhipin_saleflow [['branch_no','card_id','flow_no','cls',' shopid_cardid','age']].\ rename (columns= {'cls':'cls_zhipin'})
Wanju_saleflow= saleflow [saleflow ['cls'] =' toy'] WANJU = wanju_saleflow [['branch_no','card_id','flow_no','cls',' shopid_cardid','age']].\ rename (columns= {'cls':'cls_wanju'})
Mianpin_saleflow= saleflow [saleflow ['cls'] = =' cotton'] MIANPIN = mianpin_saleflow [['branch_no','card_id','flow_no','cls',' shopid_cardid','age']].\ rename (columns= {'cls':'cls_mianpin'})
Fushi_saleflow= saleflow [saleflow ['cls'] = =' supplementary food'] FUSHI = fushi_saleflow [['branch_no','card_id','flow_no','cls',' shopid_cardid','age']].\ rename (columns= {'cls':'cls_fushi'})
Fuwu_saleflow= saleflow [saleflow ['cls'] =' Service'] FUWU = fuwu_saleflow [['branch_no','card_id','flow_no','cls',' shopid_cardid','age']].\ rename (columns= {'cls':'cls_fuwu'})
Chechuang_saleflow= saleflow [saleflow ['cls'] = =' lathe'] CHECHUANG = fushi_saleflow [['branch_no','card_id','flow_no','cls',' shopid_cardid','age']].\ rename (columns= {'cls':'cls_chechuang'})
Final merger
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')
Connect all kinds of strings to get the order shopping basket
RESULT = RESUT.replace (np.nan,'') RESULT ['order shopping basket'] = 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']
At this point, the study of "python Shopping case Analysis" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.