开始使用免费开始使用

绘制每小时逮捕率

在本练习中,您将基于 hourly_arrest_rate 对象绘制折线图。此处使用折线图很合适,因为您要展示某个数量随时间的变化。

该图将帮助您发现一些仅看原始数字时不容易看出的趋势。

本练习是课程的一部分

使用 pandas 分析警务活动

查看课程

练习说明

  • 使用别名 plt 导入 matplotlib.pyplot
  • 使用 .plot() 方法为 hourly_arrest_rate 创建折线图。
  • 将 x 轴标记为 'Hour',将 y 轴标记为 'Arrest Rate',并将图标题设为 'Arrest Rate by Time of Day'
  • 使用 .show() 函数显示图形。

交互式实操练习

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

# Import matplotlib.pyplot as plt


# Create a line plot of 'hourly_arrest_rate'


# Add the xlabel, ylabel, and title
plt.xlabel(____)
plt.ylabel(____)
plt.title(____)

# Display the plot
编辑并运行代码