ComeçarComece de graça

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.

Este exercício faz parte do curso

Interactive Data Visualization with Bokeh

Ver curso

Instruções do exercício

  • 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.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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)
Editar e executar o código