Profile picture

Merging Tables Using Exact Match

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

 Exercises

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

green-divider

Read products, descriptions and merchants sheets

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

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

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

merchants.head()

green-divider

  Use pd.merge to add the description on each product

In [ ]:
# your code goes here
In [ ]:
prod_descr = pd.merge(products, descriptions, on='product_id')

prod_descr.head(10)

green-divider

  Use pd.merge to add the merchant name on each product

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

prod_merch.head(10)

purple-divider

Notebooks AI
Notebooks AI Profile20060