Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Case Analysis of python Shopping

Shulou Source: shulou.com Published: 2022-05-31 13:13:04 10月01日 Update

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!

Tags: Milk powder shopping running water symbiosis analysis categories nutrition examples case analysis brands categories nutrition learning supplies shopping baskets more toys categories orders supplementary food Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia OPPO Reno Microsoft Shulou Technology MySQL