From e8b416977f937edb6b42e33f609610d6c6b2e287 Mon Sep 17 00:00:00 2001 From: Zee Shen <150317462+szhouling@users.noreply.github.com> Date: Thu, 12 Sep 2024 21:42:10 -0700 Subject: [PATCH 1/3] Create 1484. Group Sold Products By The Date --- 1484. Group Sold Products By The Date | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 1484. Group Sold Products By The Date diff --git a/1484. Group Sold Products By The Date b/1484. Group Sold Products By The Date new file mode 100644 index 0000000..7a48735 --- /dev/null +++ b/1484. Group Sold Products By The Date @@ -0,0 +1,11 @@ +import pandas as pd + +def categorize_products(activities: pd.DataFrame) -> pd.DataFrame: + groups = activities.groupby(['sell_date']) + result = groups.agg( + num_sold = ('product', 'nunique'), + products = ('product', lambda x : ','.join( + sorted(set(x)) + )) + ).reset_index() + return result.sort_values(by = ['sell_date']) From 88555877a2e5fff4cae236e9ba2ccbdee6fccabe Mon Sep 17 00:00:00 2001 From: Zee Shen <150317462+szhouling@users.noreply.github.com> Date: Thu, 12 Sep 2024 21:52:20 -0700 Subject: [PATCH 2/3] Create 1693. Daily Leads and Partners --- 1693. Daily Leads and Partners | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 1693. Daily Leads and Partners diff --git a/1693. Daily Leads and Partners b/1693. Daily Leads and Partners new file mode 100644 index 0000000..33579f8 --- /dev/null +++ b/1693. Daily Leads and Partners @@ -0,0 +1,8 @@ +import pandas as pd + +def daily_leads_and_partners(daily_sales: pd.DataFrame) -> pd.DataFrame: + groups = daily_sales.groupby(['date_id', 'make_name']).agg( + unique_leads = ('lead_id', 'nunique'), + unique_partners = ('partner_id', 'nunique') + ).reset_index() + return groups From 235950c239bd4a923b02abc3526ce91dcf3a9220 Mon Sep 17 00:00:00 2001 From: Zee Shen <150317462+szhouling@users.noreply.github.com> Date: Thu, 12 Sep 2024 21:52:49 -0700 Subject: [PATCH 3/3] Create 1050. Actors and Directors Who Cooperated At Least Three Times --- ...Actors and Directors Who Cooperated At Least Three Times | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 1050. Actors and Directors Who Cooperated At Least Three Times diff --git a/1050. Actors and Directors Who Cooperated At Least Three Times b/1050. Actors and Directors Who Cooperated At Least Three Times new file mode 100644 index 0000000..7c97336 --- /dev/null +++ b/1050. Actors and Directors Who Cooperated At Least Three Times @@ -0,0 +1,6 @@ +import pandas as pd + +def actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame: + grouped = actor_director.groupby(['actor_id', 'director_id']).size().reset_index(name = 'count') + grouped = grouped[grouped['count'] >= 3] + return grouped[['actor_id', 'director_id']]