Profile picture

Merging Tables With Missing Data

Last updated: July 24th, 20192019-07-24Project preview

 Exercises

In [ ]:
import numpy as np
import pandas as pd
In [ ]:
excel_file = pd.ExcelFile('2. Products (exercises).xlsx')
In [ ]:
excel_file.sheet_names

green-divider

Read products and merchants sheets

In [ ]:
# your code goes here
In [ ]:
products = excel_file.parse('Products list')

products.head()
In [ ]:
# your code goes here
In [ ]:
merchants = excel_file.parse('Merchants list')

merchants.head()

green-divider

  Use pd.merge to add the merchant name on each product, using inner join strategy

In [ ]:
# your code goes here
In [ ]:
prod_merch_inner = pd.merge(products, merchants, left_on='merchant_id', right_on='code')

prod_merch_inner.head(10)

green-divider

  Use pd.merge to add the merchant name on each product, using left join strategy

In [ ]:
# your code goes here
In [ ]:
prod_merch_left = pd.merge(products, merchants, left_on='merchant_id', right_on='code', how='left')

prod_merch_left.head(10)

purple-divider

Notebooks AI
Notebooks AI Profile20060