Count items greater than a value in pandas groupby

后端 未结 4 1360
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-17 08:49

I have the Yelp dataset and I want to count all reviews which have greater than 3 stars. I get the count of reviews by doing this:

reviews.groupby(\'business         


        
4条回答
  •  情书的邮戳
    2021-01-17 09:21

    I quite like using method chaining with Pandas as I find it easier to read. I haven't tried it but I think this should also work

    reviews.query("stars > 3").groupby("business_id").size()
    

提交回复
热议问题