From c4e0c508600a3899eba9e2e217238d507cda249e Mon Sep 17 00:00:00 2001 From: Punya Ira Anand Date: Tue, 1 Apr 2025 13:59:50 -0500 Subject: [PATCH 1/6] Create Group Sold Products by the Date --- Group Sold Products by the Date | 1 + 1 file changed, 1 insertion(+) create mode 100644 Group Sold Products by the Date diff --git a/Group Sold Products by the Date b/Group Sold Products by the Date new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Group Sold Products by the Date @@ -0,0 +1 @@ + From ecbd876f390a6b8d23bf14352f1d78b7db301dc6 Mon Sep 17 00:00:00 2001 From: Punya Ira Anand Date: Tue, 1 Apr 2025 14:00:29 -0500 Subject: [PATCH 2/6] Create Daily Leads and Partners --- Daily Leads and Partners | 1 + 1 file changed, 1 insertion(+) create mode 100644 Daily Leads and Partners diff --git a/Daily Leads and Partners b/Daily Leads and Partners new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Daily Leads and Partners @@ -0,0 +1 @@ + From 3f0517a8f61f8f5dde832d27a1b4a950f32a7b74 Mon Sep 17 00:00:00 2001 From: Punya Ira Anand Date: Tue, 1 Apr 2025 14:00:59 -0500 Subject: [PATCH 3/6] Create Actors and Directors who Cooperated At Least Three Times --- Actors and Directors who Cooperated At Least Three Times | 1 + 1 file changed, 1 insertion(+) create mode 100644 Actors and Directors who Cooperated At Least Three Times diff --git a/Actors and Directors who Cooperated At Least Three Times b/Actors and Directors who Cooperated At Least Three Times new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Actors and Directors who Cooperated At Least Three Times @@ -0,0 +1 @@ + From 7f234dd166231ee694950443f28aa537bcfde9e2 Mon Sep 17 00:00:00 2001 From: Punya Ira Anand Date: Tue, 1 Apr 2025 14:18:10 -0500 Subject: [PATCH 4/6] Update Group Sold Products by the Date --- Group Sold Products by the Date | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Group Sold Products by the Date b/Group Sold Products by the Date index 8b13789..70c368f 100644 --- a/Group Sold Products by the Date +++ b/Group Sold Products by the Date @@ -1 +1,13 @@ +import pandas as pd +def categorize_products(activities: pd.DataFrame) -> pd.DataFrame: + if activities.empty: # Handle case where there's no data + return pd.DataFrame(columns=["sell_date", "num_sold", "products"]) + + # Group by sell_date and compute required fields + result = activities.groupby("sell_date").agg( + num_sold=("product", "nunique"), # Count unique products + products=("product", lambda x: ",".join(sorted(x.unique()))) # Sort and join product names + ).reset_index() + + return result From f4d03d7ed135b0224ac6870fad9b17c28028b728 Mon Sep 17 00:00:00 2001 From: Punya Ira Anand Date: Tue, 1 Apr 2025 14:28:25 -0500 Subject: [PATCH 5/6] Update Daily Leads and Partners --- Daily Leads and Partners | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Daily Leads and Partners b/Daily Leads and Partners index 8b13789..e9ca9de 100644 --- a/Daily Leads and Partners +++ b/Daily Leads and Partners @@ -1 +1,13 @@ +import pandas as pd +def daily_leads_and_partners(daily_sales: pd.DataFrame) -> pd.DataFrame: + if daily_sales.empty: # Handle case where there's no data + return pd.DataFrame(columns=["date_id", "make_name", "unique_leads", "unique_partners"]) + + # Group by date_id and make_name, and count unique leads and partners + result = daily_sales.groupby(["date_id", "make_name"]).agg( + unique_leads=("lead_id", "nunique"), + unique_partners=("partner_id", "nunique") + ).reset_index() + + return result From 92f5b7caa0920e0e5f40fde4ba295112f344d564 Mon Sep 17 00:00:00 2001 From: Punya Ira Anand Date: Tue, 1 Apr 2025 14:32:54 -0500 Subject: [PATCH 6/6] Update Actors and Directors who Cooperated At Least Three Times --- ...ectors who Cooperated At Least Three Times | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Actors and Directors who Cooperated At Least Three Times b/Actors and Directors who Cooperated At Least Three Times index 8b13789..684515a 100644 --- a/Actors and Directors who Cooperated At Least Three Times +++ b/Actors and Directors who Cooperated At Least Three Times @@ -1 +1,24 @@ +import pandas as pd + +def actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame: + #long version - have a dcitionary in place where actor id and director id are stored in form of tuple + + # dict = {} + # for i in range(len(actor_director)): + # a_id = actor_director['actor_id'][i] + # d_id = actor_director['director_id'][i] + # if (a_id,d_id) not in dict: + # dict[(a_id,d_id)] =0 + # dict[(a_id,d_id)] +=1 + + # result =[] + # for key,value in dict.items(): + # if value >=3: + # result.append(key) + # return pd.DataFrame(result, columns = ['actor_id','director_id']) + + #pandas solution + df = actor_director.groupby(['actor_id','director_id']).size().reset_index(name='count') + return df[df['count'] >= 3][['actor_id', 'director_id']] +