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, we'll introduce you to the merge() function and the arguments used to successfully merge two datasets.
Data files
Definitions
- DataFrame - a two-dimensional data structure, arranged in rows and columns
Similar terms
- DataFrame ⇔ dataset
- record ⇔ row
- field ⇔ column
Load data into pandas
billboard = pd.read_csv("Billboard_100_2017-2018.csv", index_col="ID")
spotify = pd.read_csv("Spotify_200_2017-2018.csv", index_col="ID")
Create DataFrames for Ariana Grande Billboard and Spotify song data
ariana_bill = billboard[billboard["Artists"].str.contains("Ariana Grande")]
ariana_spot = spotify[spotify["Artists"].str.contains("Ariana Grande")]
Merge Ariana Billboard dataset and Ariana Spotify dataset
ariana_combined = pd.merge(ariana_bill, ariana_spot, how='left', on=['Name', 'Artists', 'BB.Week'])
Additional Resources
- Pandas API: merge() function
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
Download the two CSV files from the
teacher's notes to make sure you remember
0:01
where you save them.
0:04
Anaconda navigator is open on my screen.
0:06
We'll run JupyterLab.
0:08
So I click the Launch button
in the JupyterLab cell.
0:10
It'll launch a new tab
in my browser window.
0:17
This is my file tree on the left,
0:20
I'll navigate to where I
downloaded my CSV files.
0:23
I created a folder specifically for
this workshop,
0:26
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