ค้นหาชื่อลูกค้าที่ซื้อผลิตภัณฑ์ที่แตกต่างกันอย่างน้อยสามรายการ
Find the names of customers who have bought by at least three distinct products.
df_order_items = pd.DataFrame(columns=['order_id', 'product_id']); df_customers = pd.DataFrame(columns=['customer_name', 'customer_id']); df_customer_orders = pd.DataFrame(columns=['customer_id', 'order_id'])
df_customer_products = df_customer_orders.merge(df_order_items, on='order_id').merge(df_customers, on='customer_id'); df_customer_products.groupby('customer_name')['product_id'].nunique()[lambda x: x >= 3]