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 concat() function and the arguments used to successfully concatenate data between two datasets.
Data files for download
Load 2019 data into pandas
billboard19 = pd.read_csv("billboard_100_2019.csv", index_col ="ID")
spotify19 = pd.read_csv("spotify_200_2019.csv", index_col ="ID")
Create DataFrames for 2019 Ariana Grande Billboard and Spotify song data
ariana_bill19 = billboard19[billboard19["Artists"].str.contains("Ariana Grande")]
ariana_spot19 = spotify19[spotify19["Artists"].str.contains("Ariana Grande")]
Concatenate 2017-2018 Ariana Grande song data with 2019 Ariana Grande song data in Billboard
ariana_bill_all = pd.concat([ariana_bill, ariana_bill19])
Concatenate 2017-2018 Ariana Grande song data with 2019 Ariana Grande song data in Spotify
ariana_spot_all = pd.concat([ariana_spot, ariana_spot19])
Additional Resources
- Pandas API: concat() 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
But, if you're in this workshop
you're probably familiar with string
0:00
concatenation, which is the combination
of two or more strings.
0:02
In Python,
this is performed with the plus operator.
0:06
For example, print
0:10
("book" + "keeper")
0:14
output is bookkeeper.
0:19
We simply combine two small
words into a new, larger word.
0:25
It's like we added the words together.
0:29
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