GROUP_CONCAT() explanation ✅ || MySQL✅ || Pandas || Beats 100% !!
Intuition\n Describe your first thoughts on how to solve this problem. \n- In order to agrregate the product into a single row grouped by sell_date, we use GROU
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- In order to agrregate the product into a single row grouped by sell_date, we use **GROUP_CONCAT()** function.\n- We can also specify the sorting condition in GROUP_CONCAT() as \n`GROUP_CONCAT(DISTINCT product ORDER BY product) as products`\n\n\n# Code\n```\n# Write your MySQL query statement below\nSELECT sell_date, COUNT(DISTINCT product) as num_sold, \n  GROUP_CONCAT(DISTINCT product ORDER BY product) as products\nFROM Activities\nGROUP BY sell_date\nORDER BY sell_date;\n```\n```\nimport pandas as pd\n\ndef group_sold_products_by_the_date(activities: pd.DataFrame) -> pd.DataFrame:\n    df = activities.groupby(\'sell_date\')[\'product\'].agg([\n        (\'num_sold\', \'nunique\'),\n        (\'products\', lambda x: \',\'.join(sorted(x.unique())))]).reset_index()\n\n    return df\n```
['MySQL', 'Pandas']