Filtering of rows in SQL's HAVING clause, translated to Python's pandas. The filtering method used here applies 'boolean masking', evaluating if a row returns True or False for the applied aggregation filter. True rows are returned to the user.
Filtering of rows in a pandas DataFrame using HAVING
In SQL:
SELECT
column_1,
AVG(column_2)
FROM
table
GROUP BY
column_1
HAVING
AVG(column_2) > 10;
In pandas:
table
.groupby('column_1')
.filter(lambda x: x['column_2'].mean() > 10)
.groupby('column_1')
['column_2'].mean()