MulaiMulai sekarang secara gratis

Sales over time

The estate agents have now asked you to examine house market activity to visualize changes in total sales over time. The melb DataFrame has been grouped on date, this time calculating total sales using the sum of the price column, and stored as melb_sales:

melb_sales = melb.groupby("date", as_index=False)["price"].sum()

source has been created from melb_sales, and preloaded for you. Your task is to format a plot to display the visualization with meaningful axes allowing for insights to be drawn.

Latihan ini adalah bagian dari kursus

Interactive Data Visualization with Bokeh

Lihat Kursus

Petunjuk latihan

  • Import the classes required to change the axis labels to datetime and numeric format.
  • Add line glyphs to the figure, assigning y as"price" versus x as"date" from source.
  • Update the format of the x-axis to months as three characters, and years as 4 digits.
  • Set the y-axis format as "$0a" to display in millions of dollars.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Import the second formatter
from bokeh.models import ____, ____
fig = figure(x_axis_label="Date", y_axis_label="Sales")

# Add line glyphs
fig.line(____)

# Format the x-axis format
fig.____[____].____ = ____(months="____")

# Format the y-axis format
fig.____[____].____ = ____(format="____")

output_file(filename="melbourne_sales.html")
show(fig)
Edit dan Jalankan Kode