This community-built FAQ covers the “Inner Merge II” 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 II
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply ( ) below!
Agree with a comment or answer? 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 !
Hi everyone,
I’m a total newbie to programming and have started with the Data Science path. Everything went (relatively ) smooth so far, however, now I stumbled upon on hurdle: In this lesson (Inner Merge II, Instruction 3) it seems, that some basic Python knowledge is already assumed.
My question : should I’ve started with the Python programming course first?
Thanks in advance!
Gabriel
1 Like
Hi, I’m having the same problem. Everything was going fine until here and now it seems to require a higher level of coding knowledge. I’m stuck!
Hi guys, any idea why join doesn’t work here?
import codecademylib
import pandas as pd
sales = pd.read_csv('sales.csv')
print(sales)
targets = pd.read_csv('targets.csv')
print(targets)
sales_vs_targets = pd.merge(sales,targets)
sales_vs_tragets_2 = sales.join(targets, on ='month' )
print(sales_vs_targets)
print(sales_vs_tragets_2)
It showed this error:
columns overlap but no suffix specified: Index([u’month’], dtype=’object’)
According to the document of the join
method (see the last example at the bottom), this method always uses index (not column) of the DataFrame given as argument. So it seems that month
column of targets
should be set as index using the set_index
method :
sales_vs_tragets_2 = sales.join(targets.set_index('month'), on='month')
ramtob
July 8, 2024, 10:08am
6
Hello,
Concerning pd.merge(), does the order of inputs matter?
That is, does pd.merge(df1, df2) produce the same result as pd.merge(df2, df1)?
Order matters. You can also use the how=
parameter of pd.merge()
Did you try it out? What happened?
See:
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.merge.html#pandas.merge
ramtob
July 9, 2024, 12:13pm
8
I found that a similar question was asked here .
It seems that, for the default merge type, the merge order affects (only) the order of columns in the result dataframe.