Combine Pandas DataFrame Rows Based on Matching Data and Boolean I have a Pandas DataFrame with sales data and columns for year, ISO week, price, quantity, and organic [boolean]. Because each row represents a different location, dates are repeated. I would like to combine rows with matching year, ISO week, and organic. Ideally, the combined row would have the average price and sum of total quantity. Any help is much appreciated!
I believe what you need is agg from pandas. You can pass a dictionary of the different aggregations you need for each column:

import pandas as pd

df = pd.DataFrame({'year':['2017','2018','2019','2019'], 
                   'ISO Week':[1,2,3,3],
                  'Price':[5,10,15,20],
                   'quantity':[1,2,3,4],
                  'organic':[True, False, True, True]})

   ISO Week  Price  organic  quantity  year
0         1      5     True         1  2017
1         2     10    False         2  2018
2         3     15     True         3  2019   #&lt;------ combine
3         3     20     True         4  2019   #&lt;------ combine

df.groupby(['year','ISO Week','organic'], as_index=False).agg({'Price':'mean', 'quantity':'sum'})

   year  ISO Week  organic  Price  quantity
0  2017         1     True    5.0         1
1  2018         2    False   10.0         2
2  2019         3     True   17.5         7