开始使用免费开始使用

每组一个可视化

在一个数据探索项目中,您需要按 "Period of stay" 和按星期几 "Review weekday" 来可视化酒店的评论数量。此可视化的目标是查看在四个停留时段中,各自哪一天的评论最多。数据集 reviews 已为您预加载,同时已导入 seaborn(命名为 sns)和 matplotlib.pyplot(命名为 plt)。

本练习是课程的一部分

在 Python 中处理分类数据

查看课程

练习说明

  • 使用 "count" 类型创建一个 catplot()
  • "Review weekday" 统计评论数量。
  • 为每个 "Period of stay" 创建单独的子图。
  • 每 2 个图换行一次。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Create a catplot for each "Period of stay" broken down by "Review weekday"
ax = sns.catplot(
  # Make sure Review weekday is along the x-axis
  ____,
  # Specify Period of stay as the column to create individual graphics for
  ____,
  # Specify that a count plot should be created
  ____,
  # Wrap the plots after every 2nd graphic.
  ____,
  data=reviews
)
plt.show()
编辑并运行代码