FAQ: Working with Multiple DataFrames - Inner Merge III


#1

This community-built FAQ covers the “Inner Merge III” 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 Inner Merge III

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!


#2

In this exercise they ask you to Merge all three DataFrames ( sales , targets , and men_women ) into one big DataFrame called all_data .
My question is why do I have to use:

df1.merge(df2).merge(df3)

instead of:

all_data = pd.merge(sales,targets,men_women)

If I understand correctly you can only use pd.merge when you have 2 columns to merge and df1.merge when you have more than 2 to merge?


#3

Guys I’m kind of lost here. In exercise 4 it says

Select the rows of all_data where:

  • revenue is greater than target

AND

  • women is greater than men

Save your answer to the variable results .

How do I apply this ‘AND’ condition in order to obtain df ‘results’ ? Someone help me please.


#4

I understand the concept- I need help with choosing the syntax…the code I wrote makes sense to me, but i doubt the syntax is correct. I wrote

results=all_data[(all_data.revenue > all_data.sales) AND (all_data.women > all_data.men)]

there’s no solution or hint button so I’m not sure- this site’s not free so they had better get back to me…


#5

Hi, I also had some trouble with this, you have to use “&”, not “AND”


#6

The problem with this you are saying ‘all_data.sales’ it should be ‘all_data.target’ and you need to use a “&” . I do agree there should probably be a hint, but this an example of a working answer:

results = all_data[(all_data.revenue > all_data.target) & (all_data.women > all_data.men)]


#7

Why are we let to guess the solution? There is not explanation. Feels awful


#8

thanks! it worked
They really should put a hint about the “&”