From 5173460882839d4f251e4d8dccca31468275f9b0 Mon Sep 17 00:00:00 2001 From: BharathVuppala96 Date: Wed, 12 Mar 2025 12:33:14 -0700 Subject: [PATCH] 3 problems completed --- Daily Leads and partners.py | 5 +++++ actors and directors.py | 6 ++++++ group sold products by the date.py | 6 ++++++ 3 files changed, 17 insertions(+) create mode 100644 Daily Leads and partners.py create mode 100644 actors and directors.py create mode 100644 group sold products by the date.py diff --git a/Daily Leads and partners.py b/Daily Leads and partners.py new file mode 100644 index 0000000..602cf92 --- /dev/null +++ b/Daily Leads and partners.py @@ -0,0 +1,5 @@ +import pandas as pd + +def daily_leads_and_partners(daily_sales: pd.DataFrame) -> pd.DataFrame: + daily_sales= daily_sales.groupby(['date_id','make_name']).nunique().reset_index() + return daily_sales.rename(columns={'lead_id':'unique_leads','partner_id':'unique_partners'}) \ No newline at end of file diff --git a/actors and directors.py b/actors and directors.py new file mode 100644 index 0000000..d54bee6 --- /dev/null +++ b/actors and directors.py @@ -0,0 +1,6 @@ +import pandas as pd + +def actors_and_directors(actor_director: pd.DataFrame) -> pd.DataFrame: + df=actor_director.groupby(['actor_id','director_id']).count().reset_index() + df=df[df['timestamp']>=3] + return df[['actor_id','director_id']] \ No newline at end of file diff --git a/group sold products by the date.py b/group sold products by the date.py new file mode 100644 index 0000000..29cd7a5 --- /dev/null +++ b/group sold products by the date.py @@ -0,0 +1,6 @@ +import pandas as pd + +def categorize_products(activities: pd.DataFrame) -> pd.DataFrame: + activities = activities.groupby(['sell_date']).agg( num_sold=('product','nunique'),products= ('product',lambda x:','.join(sorted(set(x))))).reset_index() + + return activities.sort_values(by=['sell_date'])