Simple sampling with pandas
Throughout this chapter, you'll be exploring song data from Spotify. Each row of this population dataset represents a song, and there are over 40,000 rows. Columns include the song name, the artists who performed it, the release year, and attributes of the song like its duration, tempo, and danceability. You'll start by looking at the durations.
Your first task is to sample the Spotify dataset and compare the mean duration of the population with the sample.
spotify_population
is available and pandas
is loaded as pd
.
This exercise is part of the course
Sampling in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Sample 1000 rows from spotify_population
spotify_sample = ____
# Print the sample
print(spotify_sample)