Project 21: Songs & Plays Merge
Data Analyst
Builds on these lessons
Current Task
Objective
pd.merge() combines two DataFrames by matching values in a shared key column, like a SQL JOIN.
Task: merge a songs DataFrame with a plays DataFrame on song_id and print the result.
index.py
import pandas as pd
songs = pd.DataFrame({'song_id': [1, 2], 'title': ['Song A', 'Song B']})
plays = pd.DataFrame({'song_id': [1, 2], 'plays': [500, 800]})
merged = pd.merge(songs, plays, on='song_id')
print(merged)
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview