diff --git a/problem2.py b/problem2.py new file mode 100644 index 0000000..8fc7b96 --- /dev/null +++ b/problem2.py @@ -0,0 +1,6 @@ +import pandas as pd + +def big_countries(world: pd.DataFrame) -> pd.DataFrame: + df=world[(world['area']>=3000000) | (world['population']>=25000000)][['name','population','area']] + print (df) + return df \ No newline at end of file diff --git a/problem3.py b/problem3.py new file mode 100644 index 0000000..9bf14f2 --- /dev/null +++ b/problem3.py @@ -0,0 +1,6 @@ +import pandas as pd + +def find_products(products: pd.DataFrame) -> pd.DataFrame: + df=products[(products['low_fats']=='Y') & (products['recyclable']=='Y')][['product_id']] + # df=df[['product_id']] + return df \ No newline at end of file diff --git a/problem4.py b/problem4.py new file mode 100644 index 0000000..9d5a10e --- /dev/null +++ b/problem4.py @@ -0,0 +1,10 @@ +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'}) + +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()][['name']].rename(columns={'name':'Customers'}) + return df \ No newline at end of file