I would like the following code to run faster (maybe using numpy ?) but I can't figure out how to do it :
df = df[['shop_id', 'brand', 'industry', 'zip_code', 'impressions', 'is_retailer']].groupby(
['shop_id', 'zip_code', 'brand']).agg(
{'impressions': 'sum', 'is_retailer': 'sum', 'industry': 'max'}).reset_index()
Basically, I want to group by a dataframe by shop_id, zip_code and brand, and perform a sum over the impressions and the column "is_retailer" and select the max of the industry.
Is there a faster way to do it? I need to perform this operation several times.
Thanks