FAQ: Working with Multiple DataFrames - Mismatched Merges

Community%20FAQs%20on%20Codecademy%20Exercises

This community-built FAQ covers the “Mismatched Merges” exercise from the lesson “Working with Multiple DataFrames”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Data Science

Data Analysis with Pandas

FAQs on the exercise Mismatched Merges

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Yes… what did happen to order 3?
Is this a rhetorical question or are we supposed to know the answer?

1 Like

I’m thinking the same …

If you go to the next lesson the answer is given

from lesson 8/11:

“In the previous exercise, we saw that when we merge two DataFrames whose rows don’t match perfectly, we lose the unmatched rows.”

1 Like

I’ve applied the following code:

print(orders)
print(products)

merged_df = orders.merge(products)

print(merged_df)

and get the following output:

Question: why is the order changed? shouldn’t it just append the additional columns into the existing order of the ‘orders’ dataframe?

1 Like

It may be wrong because I don’t understand the internal operation of the merge method exactly, but it seems that rows are organized by each value of product_id, the join key, respectively.

The values of product_id in orders is 3, 2, … So I’m guessing that the joining process is organized in this order (rows whose product_id is 3, and then rows whose product_id is 2, …).

I’ll appreciate if someone who knows exactly will reply.