Grouped subsets iteration loop

Task:Calculate how many months it takes for each sales representative to reach the sales amount of 50k.

Python

1 import pandas as pd
2 sale_file = "E:/txt/orders_i.csv"
3 sale_data = pd.read_csv(sale_file,sep='\t')
4 sale_g = sale_data.groupby('sellerid')
5 breach50_list = []
6 for index,group in sale_g:
7     amount=0
8     group = group.sort_values('month')
9     for row in group.itertuples():
10         amount+=getattr(row, 'amount')
11         if amount>=500000:
12             breach50_list.append([index,getattr(row, 'month'),])
13             break
14 breach50_df = pd.DataFrame(breach50_list,columns=['sellerid','month'])
15 print(breach50_df)

esProc

  A  
1 E:/txt/orders_i.csv  
2 =file(A1).import@t()  
3 =A2.group(sellerid;(~.iterate((x=month,~~+amount),0,~~>500000),x):breach50)  

esProc retains grouped subsets and uses the iterative function to realize the iteration.