In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
In this article, the editor introduces "python application case analysis" in detail, the content is detailed, the steps are clear, and the details are handled properly. I hope this "python application case analysis" article can help you solve your doubts.
In this quarter, how many new customers of milk powder have been driven by buying probiotics?
# naifen_vipflow.columnsss1= naifen_vipflow [['flow_no','shopid_cardid','item_name']] .rename (columns= {' item_name':'item_name_naifen'}) ss2 = ysj_vipflow [['flow_no','item_name']] .rename (columns= {' item_name':'item_name_ysj'}) flow_no_naifen_ysj= ss1.merge (ss2, on='flow_no') # orders and members for simultaneous purchase of probiotics and milk powder
# flow_no_naifen_ysjformer_quarter_start_end= ['2019-10-01 00 groupby_list_vip groupby_list_vip = [' shopid_cardid','shopid_branch',' Rank'] groupby_list_branch= ['2020-01-01 00 groupby_list_vip] 'Rank'] # naifen_vipflow.columns# milk powder new customer # each member buys for the first time That is, the new customer's pipelining saleflow= naifen_vipflowsaleflow_first = saleflow.groupby (groupby_list_vip). Oper_date.min (). Reset_index (). Rename (columns= {'oper_date':'date_1st'}) # pick out the new customers in the previous quarter, former_new = saleflow_first [(saleflow_first [' date_1st'] pd.to_datetime (former_quarter_start_ end [0]))] # the new customers in the next quarter. That is, the current quarter after_new = saleflow_first [(saleflow_first ['date_1st'] pd.to_datetime (after_quarter_start_ end [0])] # selects the flow of the next quarter, that is, the current quarter after_flow = saleflow [(saleflow [' oper_date'] pd.to_datetime (after_quarter_start_ end [0]))] # # the new customers in the next quarter Bought the order number after_new_naifen_ysj= after_new.merge (flow_no_naifen_ysj) #. Shopid_cardid.nunique () of milk powder and probiotics at the same time.
Organize it into a function
Def ysj_naifen_new (ysj_hsy_vipflow, naifen_vipflow, former_quarter_start_end=], groupby_list_vip = ['2019-10-01 00lv 00L'], after_quarter_start_end= ['2020-01-01 0000RV 00L'], groupby_list_vip = [''shopid_cardid'' 'shopid_branch',' Rank']: "" Parameter: ysj_hsy_vipflow: member flow of probiotics naifen_vipflow: milk powder member flow former_quarter_start_end: range of the previous time period after_quarter_start_end: range of the next time period groupby_list_vip: member level grouping Included in groupby () That is, groupby (groupby_list_vip) "" ss1= naifen_vipflow [['flow_no','shopid_cardid','item_name']] .rename (columns= {' item_name':'item_name_naifen'}) ss2 = ysj_vipflow [['flow_no','item_name']] .rename (columns= {' item_name':'item_name_ysj'}) flow_no_naifen_ysj= ss1.merge (ss2 On='flow_no') # order number saleflow= naifen_vipflow saleflow_first = saleflow.groupby (groupby_list_vip). Oper_date.min (). Reset_index (). Rename (columns= {'oper_date':'date_1st'}) # pick out the new customers in the previous quarter former_new = saleflow_first [(saleflow_first [' date_]) 1st'] pd.to_datetime (former_quarter_start_ end [0])] # New customers in the second quarter after_new = saleflow_first [(saleflow_first ['date_1st'] pd.to_datetime (after_quarter_start_ end [0]))] # pick out the pipelining after_flow = saleflow in the next quarter [(saleflow [' oper_date'] pd.to_datetime (after_quarter_start_end [0])) )] # among the new customers in the first quarter Bought milk powder and probiotics after_new_naifen_ysj= after_new.merge (flow_no_naifen_ysj) #. Shopid_cardid.nunique () return after_new_naifen_ysj
Count the id of members in the result
After reading this, the article "python Application case Analysis" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, you are welcome to follow the industry information channel.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.