我有以下代码:
myData_agg = myData.groupby("Customer")["PurchAmount"].sum()
myData_agg.loc[myData_agg>=100,]我可以在一个过程中编写这段代码吗?谢谢!
发布于 2017-07-06 21:49:20
选项一:
使用[]和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])https://stackoverflow.com/questions/44950820
复制相似问题