LoslegenKostenlos starten

Building a popularity histogram

You've calculated quantiles and binned streams - now visualize the full popularity distribution to complete your analysis. The popularity column from the Spotify dataset ranges from 0 to 100. Build histogram counts with custom bin edges, then plot the distribution with Plotly to see where most albums cluster.

polars is loaded as pl and plotly.express as px. The DataFrame spotify is available.

Diese Übung ist Teil des Kurses

<Kurs>Data Transformation with Polars</Kurs>
Kurs ansehen

Übungsanweisungen

  • Build histogram counts from popularity with bins at 0, 25, 50, 75, and 100.
  • Create a bar chart with category on the x-axis and count on the y-axis.

Interaktive praktische Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Build histogram counts with custom bins
hist = spotify["popularity"].____(bins=[0, 25, 50, ____, ____])

# Create a bar chart of the distribution
fig = px.____(hist, x="____", y="____")
fig.show()
Code bearbeiten und ausführen