From c10a7871990a651e9a0e4b9e5416fc93e0fb1ccc Mon Sep 17 00:00:00 2001 From: Hinduja Cheela Date: Mon, 9 Jun 2025 14:47:05 -0500 Subject: [PATCH] Added three problems --- problem2.py | 6 ++++++ problem3.py | 6 ++++++ problem4.py | 10 ++++++++++ 3 files changed, 22 insertions(+) create mode 100644 problem2.py create mode 100644 problem3.py create mode 100644 problem4.py diff --git a/problem2.py b/problem2.py new file mode 100644 index 0000000..8fc7b96 --- /dev/null +++ b/problem2.py @@ -0,0 +1,6 @@ +import pandas as pd + +def big_countries(world: pd.DataFrame) -> pd.DataFrame: + df=world[(world['area']>=3000000) | (world['population']>=25000000)][['name','population','area']] + print (df) + return df \ No newline at end of file diff --git a/problem3.py b/problem3.py new file mode 100644 index 0000000..9bf14f2 --- /dev/null +++ b/problem3.py @@ -0,0 +1,6 @@ +import pandas as pd + +def find_products(products: pd.DataFrame) -> pd.DataFrame: + df=products[(products['low_fats']=='Y') & (products['recyclable']=='Y')][['product_id']] + # df=df[['product_id']] + return df \ No newline at end of file diff --git a/problem4.py b/problem4.py new file mode 100644 index 0000000..9d5a10e --- /dev/null +++ b/problem4.py @@ -0,0 +1,10 @@ +import pandas as pd + +def find_customers(customers: pd.DataFrame, orders: pd.DataFrame) -> pd.DataFrame: + df=customers[~customers['id'].isin(orders['customerId'])] + return df[['name']].rename(columns={'name':'Customers'}) + +def find_customers(customers: pd.DataFrame, orders: pd.DataFrame) -> pd.DataFrame: + df=customers.merge(orders,left_on='id',right_on='customerId',how='left') + df=df[df['customerId'].isna()][['name']].rename(columns={'name':'Customers'}) + return df \ No newline at end of file