I have the pandas dataframe "data", and want to keep only the rows where the sum of "numb_people" per category "class" is at least 2.
This, however, throws an index error (the indices do not match anymore):
data = data[data.groupby('class').sum()['numb_people'] > 2]
How can I do this in a similarly simple manner?