[Pandas] || My Approach with Clear Comments...
\n\n# Code\n\nimport pandas as pd\n\ndef categorize_products(activities: pd.DataFrame) -> pd.DataFrame:\n    # Group the activities by sell_date and collect the
\n\n# Code\n```\nimport pandas as pd\n\ndef categorize_products(activities: pd.DataFrame) -> pd.DataFrame:\n    # Group the activities by sell_date and collect the unique products for each date\n    grouped = activities.groupby(\'sell_date\')[\'product\'].agg([\'nunique\', lambda x: \',\'.join(sorted(set(x)))]).reset_index()\n    \n    # Rename the columns for clarity\n    grouped.columns = [\'sell_date\', \'num_sold\', \'products\']\n    \n    # Replace variations of \'Mask\' with just \'Mask\'\n    grouped[\'products\'] = grouped[\'products\'].str.replace(r\'(^|,)Mask(,|$)\', r\'\\1Mask\\2\')\n    \n    # Sort the result table by sell_date\n    result = grouped.sort_values(by=\'sell_date\')\n    \n    return result\n\n```\n![upvote img.jpg](https://assets.leetcode.com/users/images/fe39393f-fae2-42ae-8f28-c486468073a2_1692727296.8042412.jpeg)\n
['Pandas']