開始使用免費開始

MSD 摘要統計

先來熟悉一下 Million Songs 的 Echo Nest Taste Profile 子集。在本課程中,我們會簡稱為 Million Songs 資料集或 msd。先取得使用者數量與歌曲數量,並查看在這個子集中哪些歌曲的播放次數最多。

本練習屬於課程

使用 PySpark 打造推薦引擎

檢視課程

練習說明

  • 使用 .show() 方法查看資料的樣子。
  • 完成程式碼以計算不同 userId 的數量。先選取 userId 欄位,接著呼叫 .distinct().count()
  • 用相同方式計算不同 songId 的數量。選取 songId 欄位,並對它呼叫 .distinct().count()

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Look at the data
msd.____()

# Count the number of distinct userIds
user_count = msd.select("____").____().count()
print("Number of users: ", user_count)

# Count the number of distinct songIds
song_count = msd.select("____").____().count()
print("Number of songs: ", song_count)
編輯並執行程式碼