diff --git a/02-BigCountries.py b/02-BigCountries.py new file mode 100644 index 0000000..190e826 --- /dev/null +++ b/02-BigCountries.py @@ -0,0 +1,6 @@ +# Problem 2 - Big Countries ( https://leetcode.com/problems/big-countries/ ) +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/03-RecyclableandLowFatProducts.py b/03-RecyclableandLowFatProducts.py new file mode 100644 index 0000000..fd5f36c --- /dev/null +++ b/03-RecyclableandLowFatProducts.py @@ -0,0 +1,6 @@ +# 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: + df = products[(products['low_fats'] == 'Y') & (products['recyclable'] == 'Y')] + return df[['product_id']] \ No newline at end of file diff --git a/04-CustomersWhoNeverOrder.py b/04-CustomersWhoNeverOrder.py new file mode 100644 index 0000000..09ff112 --- /dev/null +++ b/04-CustomersWhoNeverOrder.py @@ -0,0 +1,6 @@ +# 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