开始使用免费开始使用

平均建筑面积

房产中介想了解建筑面积是否随时间发生了变化。

您将按 datemelb 数据集分组,并计算平均建筑面积。然后,您会将分组后的 DataFrame 转换为 Bokeh 的 source 对象,并构建一幅折线图。

本练习是课程的一部分

使用 Bokeh 进行交互式数据可视化

查看课程

练习说明

  • datemelb 分组,并计算 "building_area" 的均值。
  • 创建 fig,分别将 x、y 轴标签设为 "Date""Building Size (Meters Squared)",并将 x 轴刻度设置为日期时间格式。
  • 使用 sourcefig 添加折线图元,展示 building_area 相对于 date 的变化。
  • 生成名为 "property_size_by_date.html" 的 HTML 文件。

交互式实操练习

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

# Group by date and calculate average building size
prop_size = melb.____("____", as_index=False)["____"].____()
source = ColumnDataSource(data=prop_size)

# Create the figure
fig = figure(x_axis_label="____", y_axis_label="____", x_axis_type="____")

# Add line glyphs
fig.____(____)

# Generate the HTML file
____
show(fig)
编辑并运行代码