diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..c38df0d Binary files /dev/null and b/.DS_Store differ diff --git a/problem1.py b/problem1.py new file mode 100644 index 0000000..aed718a --- /dev/null +++ b/problem1.py @@ -0,0 +1,8 @@ +import pandas as pd + +lst = [['FirstName1', 'LastName1'], + ['FirstName2', 'LastName2'], + + +df = pd.DataFrame(lst, columns =['First_Name', 'Last_Name']) +print(df ) \ No newline at end of file diff --git a/problem2.py b/problem2.py new file mode 100644 index 0000000..4fd4c7f --- /dev/null +++ b/problem2.py @@ -0,0 +1,9 @@ +import pandas as pd + +def big_countries(world: pd.DataFrame) -> pd.DataFrame: + + condition = world[(world['area'] >= 3000000) | (world['population'] >= 25000000)] + df = condition[['name','population','area']] + + return df + diff --git a/problem3.py b/problem3.py new file mode 100644 index 0000000..286e6dc --- /dev/null +++ b/problem3.py @@ -0,0 +1,9 @@ +import pandas as pd + +def find_products(products: pd.DataFrame) -> pd.DataFrame: + '''Simple pandas & condition''' + condition = products[(products['low_fats'] == 'Y') & (products['recyclable'] == 'Y')] + + product_ids = condition[['product_id']] + + return product_ids \ No newline at end of file diff --git a/problem4.py b/problem4.py new file mode 100644 index 0000000..49cdfb0 --- /dev/null +++ b/problem4.py @@ -0,0 +1,5 @@ +import pandas as pd + +def find_customers(customers: pd.DataFrame, orders: pd.DataFrame) -> pd.DataFrame: + condition = customers[~customers['id'].isin(orders['customerId'])] + return condition[['name']].rename(columns={'name': 'Customers'})