始める無料で始める

MSD の要約統計

Million Songs の Echo Nest Taste Profile サブセットに慣れていきましょう。このコースでは便宜上、Million Songs データセットまたは msd と呼びます。ユーザー数と楽曲数を求めましょう。また、このサブセットで再生回数が最も多い曲も確認しましょう。

この演習はコースの一部です

PySpark で作る Recommendation Engines

コースを見る

演習の手順

  • .show() メソッドを使って、データの中身を確認しましょう。
  • 一意な userId の件数を数えるコードを完成させてください。userId 列を選択し、.distinct().count() を呼び出します。
  • 次に songId に対して同じことを行い、一意な 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)
コードを編集して実行