diff --git a/Problem 2 BigCountries.py b/Problem 2 BigCountries.py new file mode 100644 index 0000000..25a3b94 --- /dev/null +++ b/Problem 2 BigCountries.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/Problem 3 Recyclable and Low Fat Products.py b/Problem 3 Recyclable and Low Fat Products.py new file mode 100644 index 0000000..77d7111 --- /dev/null +++ b/Problem 3 Recyclable and Low Fat Products.py @@ -0,0 +1,4 @@ +import pandas as pd + +def find_products(products: pd.DataFrame) -> pd.DataFrame: + return products[(products['low_fats']=='Y') & (products['recyclable']=='Y')][['product_id']] \ No newline at end of file diff --git a/Problem 4 Customer Who Never Order.py b/Problem 4 Customer Who Never Order.py new file mode 100644 index 0000000..5527024 --- /dev/null +++ b/Problem 4 Customer Who Never Order.py @@ -0,0 +1,5 @@ +import pandas as pd + +def find_customers(customers: pd.DataFrame, orders: pd.DataFrame) -> pd.DataFrame: + return customers[~customers['id'].isin(orders['customerId'])][['name']].rename(columns ={'name':'Customers'}) + \ No newline at end of file diff --git a/README.md b/README.md index a51355c..a781f87 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 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/) +1 Problem 1 : Make a Pandas DataFrame with two-dimensional list ( https://www.geeksfor geeks.org/make-a-pandas-dataframe-with-two-dimensional-list-python/) 2 Problem 2 :Big Countries ( https://leetcode.com/problems/big-countries/ )