diff --git a/Big Countries b/Big Countries new file mode 100644 index 0000000..15d31c7 --- /dev/null +++ b/Big Countries @@ -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']] diff --git a/Customers Who Never Order b/Customers Who Never Order new file mode 100644 index 0000000..4d47648 --- /dev/null +++ b/Customers Who Never Order @@ -0,0 +1,8 @@ +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'}) + df = customers.merge(orders, left_on="id", right_on ="customerId", how="left") + df = df[df["customerId"].isna()] + return df[['name']].rename(columns={'name':'Customers'}) diff --git a/Dataframe from a 2-D list b/Dataframe from a 2-D list new file mode 100644 index 0000000..85fa7c1 --- /dev/null +++ b/Dataframe from a 2-D list @@ -0,0 +1,9 @@ +# import pandas as pd +import pandas as pd + +# List1 +lst = [['This is', 1], ['a', 2], ['learning', 3], ['program', 4]] + +# creating df object +df = pd.DataFrame(lst, columns =['Tag', 'number']) +print(df ) diff --git a/Recyclable and Low Fat Products b/Recyclable and Low Fat Products new file mode 100644 index 0000000..fda9abd --- /dev/null +++ b/Recyclable and Low Fat Products @@ -0,0 +1,5 @@ +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']]