使用 pandas 進行簡單抽樣
在本章中,你將探索來自 Spotify 的歌曲資料。這個母體資料集的每一列代表一首歌,總共有超過 40,000 列。欄位包含歌曲名稱、演出歌手、發行年份,以及歌曲的屬性,例如時長、節奏(tempo)與可舞性(danceability)。你會先從觀察歌曲時長開始。
你的第一個任務是對 Spotify 資料集進行抽樣,並比較母體與樣本的平均時長。
已提供 spotify_population,且已將 pandas 載入為 pd。
本練習屬於課程
Python 中的抽樣
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Sample 1000 rows from spotify_population
spotify_sample = ____
# Print the sample
print(spotify_sample)