2017-07-06 64 views
0

我有以下代碼:鏈接aggreggation程序

myData_agg = myData.groupby("Customer")["PurchAmount"].sum() 
myData_agg.loc[myData_agg>=100,] 

我可以寫一個程序代碼? 謝謝!

回答

3

選項之一:

鏈它們與[]lambda表達式:

myData.groupby("Customer")["PurchAmount"].sum()[lambda x: x >= 100] 

方法二:

使用compress方法:

myData.groupby("Customer")["PurchAmount"].sum().compress(lambda x: x >= 100) 

方案三:

使用pipe

myData.groupby("Customer")["PurchAmount"].sum().pipe(lambda x: x[x >= 100])