开始使用免费开始使用

MSD 汇总统计

先熟悉一下 Million Songs Echo Nest Taste Profile 的数据子集。在本课程中,我们将其简称为 Million Songs 数据集或 msd。请获取用户数量和歌曲数量。还要查看在这个子集中哪些歌曲的播放次数最多。

本练习是课程的一部分

使用 PySpark 构建推荐引擎

查看课程

练习说明

  • 使用 .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)
编辑并运行代码