From 9fbcc5f69194627207661ab5ec4b27d83e74bd68 Mon Sep 17 00:00:00 2001 From: Pranathi Date: Mon, 9 Jun 2025 14:19:35 -0700 Subject: [PATCH] Pandas1 submitted --- Problem1.py | 4 ++++ Problem2.py | 5 +++++ Problem3.py | 5 +++++ Problem4.py | 6 ++++++ 4 files changed, 20 insertions(+) create mode 100644 Problem1.py create mode 100644 Problem2.py create mode 100644 Problem3.py create mode 100644 Problem4.py diff --git a/Problem1.py b/Problem1.py new file mode 100644 index 0000000..daa6435 --- /dev/null +++ b/Problem1.py @@ -0,0 +1,4 @@ +import pandas as pd +list1 = [['Math', 50], ['Science',45], ['Social', 40], ['Arts', 50]] +df = pd.DataFrame(list1, columns = ['Subject', 'Marks']) +print (df) \ No newline at end of file diff --git a/Problem2.py b/Problem2.py new file mode 100644 index 0000000..25a3b94 --- /dev/null +++ b/Problem2.py @@ -0,0 +1,5 @@ +import pandas as pd + +def big_countries(world: pd.DataFrame) -> pd.DataFrame: + df = world[(world['area']>=3000000) | (world['population']>=25000000)] + return df[['name','population','area']] \ No newline at end of file diff --git a/Problem3.py b/Problem3.py new file mode 100644 index 0000000..4e658fc --- /dev/null +++ b/Problem3.py @@ -0,0 +1,5 @@ +import pandas as pd + +def find_products(products: pd.DataFrame) -> pd.DataFrame: + df = products[(products['low_fats'] == 'Y') & (products['recyclable'] == 'Y')] + return df[['product_id']] \ No newline at end of file diff --git a/Problem4.py b/Problem4.py new file mode 100644 index 0000000..3916441 --- /dev/null +++ b/Problem4.py @@ -0,0 +1,6 @@ +import pandas as pd + +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()] + return df[['name']].rename(columns = {'name':'Customers'}) \ No newline at end of file