diff --git a/Problem1-1484-group-sold-products-by-date.py b/Problem1-1484-group-sold-products-by-date.py new file mode 100644 index 0000000..df198d6 --- /dev/null +++ b/Problem1-1484-group-sold-products-by-date.py @@ -0,0 +1,10 @@ +import pandas as pd + + +def categorize_products(activities: pd.DataFrame) -> pd.DataFrame: + df = activities.groupby("sell_date").agg( + num_sold=("product", "nunique"), + products=("product", lambda x: ",".join(sorted(set(x)))) + ).reset_index() + + return df.sort_values(by=['sell_date']) \ No newline at end of file diff --git a/problem2-1693-Daily-Leads-and-Partners.py b/problem2-1693-Daily-Leads-and-Partners.py new file mode 100644 index 0000000..37395c0 --- /dev/null +++ b/problem2-1693-Daily-Leads-and-Partners.py @@ -0,0 +1,10 @@ +import pandas as pd + +def daily_leads_and_partners(daily_sales: pd.DataFrame) -> pd.DataFrame: + + df = daily_sales.groupby(["date_id", "make_name"]).agg( + unique_leads=("lead_id", "nunique"), + unique_partners=("partner_id", "nunique") + ).reset_index() + + return df \ No newline at end of file diff --git a/problem3-1050-actors-and-directors.py b/problem3-1050-actors-and-directors.py new file mode 100644 index 0000000..737a8a9 --- /dev/null +++ b/problem3-1050-actors-and-directors.py @@ -0,0 +1,7 @@ +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