Pandas, groupby where column value is greater than x

前端 未结 2 1864
日久生厌
日久生厌 2021-01-18 08:16

I have a table like this

    timestamp   avg_hr  hr_quality  avg_rr  rr_quality  activity    sleep_summary_id

    1422404668  66      229             0              


        
2条回答
  •  借酒劲吻你
    2021-01-18 08:53

    I know this is old but I wanted to add that there is an official function to do exactly this. Transforming the example from pandas to your case:

    grouped_df2= df2.groupby([df2.index.hour,'sleep_summary_id','rr_quality'])
    grouped_df2.filter(lambda x: x['rr_quality'] > 0.)
    

提交回复
热议问题