Skip to Content
Working with Multiple DataFrames
Inner Merge III

In addition to using pd.merge, each DataFrame has its own merge method. For instance, if you wanted to merge orders with customers, you could use:

new_df = orders.merge(customers)

This produces the same DataFrame as if we had called pd.merge(orders, customers).

We generally use this when we are joining more than two DataFrames together because we can “chain” the commands. The following command would merge orders to customers, and then the resulting DataFrame to products:

big_df = orders.merge(customers)\ .merge(products)



We have some more data from Cool T-Shirts Inc. The number of men’s and women’s t-shirts sold per month is in a file called men_women_sales.csv. Load this data into a DataFrame called men_women.


Merge all three DataFrames (sales, targets, and men_women) into one big DataFrame called all_data.


Display all_data using print.


Cool T-Shirts Inc. thinks that they have more revenue in months where they sell more women’s t-shirts.

Select the rows of all_data where:

  • revenue is greater than target


  • women is greater than men

Save your answer to the variable results.

Folder Icon

Sign up to start coding

Already have an account?