Data Wrangling
Importing Data Select, Drop & Rename Filter, Sort & Sample Add Columns Cleaning Data Dates & Time Join Data Aggregate & Transform
Data Analysis
Exploring Data Plotting Continuous Variables Plotting Discrete Variables
Machine Learning
Data Preparation Linear Models
Other Tutorials & Content
Learn Python for Data Science Learn Alteryx Blog



Join DataFrames with Python Pandas

Inner Join Using Merge

Create a new DataFrame called order_lines that joins the orders and products DataFrames on the "ProductID" and "Product_ID" fields using an inner join:

order_lines = orders.merge(products, left_on='ProductID', right_on='Product_ID' , how='inner')

Left Outer Join Using Merge

Create a new DataFrame called order_lines that joins the orders and products DataFrames on the "ProductID" and "Product_ID" fields using a left outer join:

order_lines = orders.merge(products, left_on='ProductID', right_on='Product_ID' , how='left')

Right Outer Join Using Merge

Create a new DataFrame called order_lines that joins the orders and products DataFrames on the "ProductID" and "Product_ID" fields using a right outer join:

order_lines = orders.merge(products, left_on='ProductID', right_on='Product_ID' , how='right')

Full Outer Join Using Merge

Create a new DataFrame called order_lines that joins the orders and products DataFrames on the "ProductID" and "Product_ID" fields using a full outer join:

order_lines = orders.merge(products, left_on='ProductID', right_on='Product_ID' , how='outer')

Concatenate Rows Using Concat

Concatenate the rows in the order_lines DataFrame with the rows in the promo_lines Dataframe:

pd.concat([orders_lines,promo_lines],axis=1)

Concatenate Columns (Union) Using Concat

Concatenate the columns in the fiction_orders DataFrame with the columns in the non_fiction_orders Dataframe:

pd.concat([fiction_orders, non_fiction_orders],axis=0)