How danceable are songs these days?
It's time to dive deeper into the Spotify data to analyze some trends in music.
In each CSV file, the 'danceability' column contains the score between 0 and 1 of how danceable each song is. The score describes how suitable a track is for dancing based on a combination of musical elements, including tempo, rhythm stability, beat strength, and overall regularity. Do you think songs are getting better or worse to dance to?
dask and the delayed() function have been imported for you. pandas has been imported as pd, and matplotlib.pyplot has been imported as plt. The list of filenames is available in your environment as filenames, and the year of each file is stored in the years list.
Este ejercicio forma parte del curso
Parallel Programming with Dask in Python
Instrucciones del ejercicio
- Inside the loop, lazily load in each file.
- Using the
'danceability'column, find the mean danceability of songs in each file. - Compute all of the results in the
danceabilitieslist, and select the first item of the resulting tuple. - Make a plot with
danceability_liston the y-axis andyearson the x-axis usingplt.plot().
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
danceabilities = []
for file in filenames:
# Lazily load in the data
df = ____
# Calculate the average danceability in the file of songs
mean_danceability = ____
danceabilities.append(mean_danceability)
# Compute all the mean danceabilities
danceability_list = ____
# Plot the results
____
plt.show()