Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Combining Data for Analysis!
You have completed Combining Data for Analysis!
Preview
Welcome! In this video, I will provide my solution to the first challenge.
Challenge 1 solution
bill_spot = pd.merge(billboard, spotify, how='left', on='[Name, Artists, BB.Week]')
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
How did you do in your first challenge?
0:00
As promised, I'll show you my solution
on how to merge the full Billboard and
0:02
Spotify data frames.
0:06
Now, I created a separate notebook so
0:08
that I could keep track of
just the challenge work.
0:10
I added some markdown so
you can follow along.
0:13
But you can do it in all the same
notebook, there's no difference.
0:15
Remember, our data frames
are named Billboard and Spotify,
0:19
Billboard on the left,
Spotify on the right.
0:23
We want to merge these datasets into a new
data frame called bill_spot,
0:26
via a left join, on our selected columns.
0:30
So we type,
bill_spot = pd.merge(
0:39
billboard, spotify,
0:48
how='left, on=['Name',
0:57
'Artists', 'BB.Week']).
1:06
Let's check the shape
of this new data frame.
1:14
bill_spot.shape.
1:19
And now let's compare it to
the Billboard data set, billboard.shape.
1:27
They have the same number of records,
as I expected for a left join.
1:33
Let's call the head function to check
columns and the first few rows of data.
1:38
bill_spot.head(),
1:43
Well that's it for this one.
1:51
In the next video, we'll learn how to
concatenate two data sets with Pandas.
1:53
See you there.
1:56
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up