Get all unique product categories by referenceOrderID
df = df[['id', 'product_category']] df_g = df.groupby('id')['product_category'].unique()