Skip to content

Spotify Song Popularity Analysis

Given Spotify song features, answer:

  • What does popularity distribution look like?
  • Which audio features correlate with popularity?
  • Do genres differ in average popularity?
diagram Spotify popularity analysis pipeline mermaid
From raw audio features to the traits that correlate with a hit.
Load spotify data
import pandas as pd
 
df = pd.read_csv("data/spotify.csv")
print(df.head())
Popularity distribution
import seaborn as sns
import matplotlib.pyplot as plt
 
plt.figure(figsize=(7, 4))
sns.histplot(df["popularity"], bins=30, kde=True)
plt.title("Popularity distribution")
plt.tight_layout()
plt.show()
Correlation
import seaborn as sns
import matplotlib.pyplot as plt
 
num = df.select_dtypes(include="number")
 
plt.figure(figsize=(8, 6))
sns.heatmap(num.corr(), cmap="coolwarm", center=0)
plt.title("Correlation heatmap")
plt.tight_layout()
plt.show()
sketch Popularity distribution p5.js
Most songs cluster in the middle; only a few reach very high popularity.
  • Top correlated features
  • Whether correlations are meaningful or driven by outliers

Exercise 3 – Select only numeric columns

Section titled “Exercise 3 – Select only numeric columns”

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading