I have a table like this
timestamp avg_hr hr_quality avg_rr rr_quality activity sleep_summary_id 1422404668 66 229 0
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.)