From 214f0568f7eb6edb4e8ef7d9f70a3e8ffe8cdb03 Mon Sep 17 00:00:00 2001 From: Paneri Patel Date: Wed, 18 Jun 2025 01:21:54 -0400 Subject: [PATCH] Done Pandas1 --- BigCountries.py | 9 +++++++++ CustomerWhoNeverOrder.py | 9 +++++++++ MakeAPandasDataFrameWithTwo-dimensionalList.py | 13 +++++++++++++ RecyclableAndLowFatProducts.py | 9 +++++++++ 4 files changed, 40 insertions(+) create mode 100644 BigCountries.py create mode 100644 CustomerWhoNeverOrder.py create mode 100644 MakeAPandasDataFrameWithTwo-dimensionalList.py create mode 100644 RecyclableAndLowFatProducts.py diff --git a/BigCountries.py b/BigCountries.py new file mode 100644 index 0000000..c80daa7 --- /dev/null +++ b/BigCountries.py @@ -0,0 +1,9 @@ +''' +2 Problem 2 :Big Countries ( https://leetcode.com/problems/big-countries/ ) +''' + +import pandas as pd + +def big_countries(world: pd.DataFrame) -> pd.DataFrame: + world = world[(world['population']>=25000000) | (world['area']>=3000000)] + return world[['name', 'population', 'area']] \ No newline at end of file diff --git a/CustomerWhoNeverOrder.py b/CustomerWhoNeverOrder.py new file mode 100644 index 0000000..a8781ba --- /dev/null +++ b/CustomerWhoNeverOrder.py @@ -0,0 +1,9 @@ +''' +4 Problem 4 :Customer Who Never Order ( https://leetcode.com/problems/customers-who-never-order/ ) +''' + +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'}) \ No newline at end of file diff --git a/MakeAPandasDataFrameWithTwo-dimensionalList.py b/MakeAPandasDataFrameWithTwo-dimensionalList.py new file mode 100644 index 0000000..5b6c3cb --- /dev/null +++ b/MakeAPandasDataFrameWithTwo-dimensionalList.py @@ -0,0 +1,13 @@ +'''Pandas1 + +1 Problem 1 : Make a Pandas DataFrame with two-dimensional list ( https://www.geeksforgeeks.org/make-a-pandas-dataframe-with-two-dimensional-list-python/) +''' + +import pandas as pd + +lst = [['Geek', 25], ['is', 30], + ['for', 26], ['Geeksforgeeks', 22]] + +df = pd.DataFrame(lst, columns =['Tag', 'number']) + +print(df) \ No newline at end of file diff --git a/RecyclableAndLowFatProducts.py b/RecyclableAndLowFatProducts.py new file mode 100644 index 0000000..c205961 --- /dev/null +++ b/RecyclableAndLowFatProducts.py @@ -0,0 +1,9 @@ +''' +3 Problem 3 :Recyclable and Low Fat Products ( https://leetcode.com/problems/recyclable-and-low-fat-products/ ) +''' + +import pandas as pd + +def find_products(products: pd.DataFrame) -> pd.DataFrame: + products = products[(products['low_fats'] == 'Y') & (products['recyclable'] == 'Y')] + return products[['product_id']] \ No newline at end of file