Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Analysis of python Application example

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

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.

Tags: Milk powder members probiotics quarter flow selection example analysis analysis application that is at the same time article Rank order content time time period scope order number Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Docker OPPO Reno vpn Shulou Information