# 17.2 GroupBy आणि merge चा सराव

Source: https://ravindrabagale.com/mr/datascience/ch17-practice-exercises-with-answer-hints/17-2-groupby-and-merge.html
Language: mr (Marathi with English technical terms)

Exercise C

फक्त Delivered rows साठी city नुसार GMV आणि unique order count काढा. Named aggregation वापरा.
Hint C पाहा
आधी status filter करा. मग groupby("city", as_index=False).agg(gmv=("amount","sum"), orders=("order_id","nunique")).

Exercise D

Stores table चा left merge करा. Store dimension मधून city न मिळालेल्या orders दाखवा.
Hint D पाहा
orders.merge(stores, on="store_id", how="left") आणि नंतर merged result वर df[df["city"].isna()]. दोन्ही tables मध्ये city column असेल तर suffixes मुळे नाव बदललेलं असू शकतं; columns तपासा.

रवींद्र बागले यांची tip

Merge च्या आधी आणि नंतर row count लिहा. Stores मधली duplicate key चुकून rows वाढवत नाही ना ते पाहा.
