Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Interactive Data Visualization with Bokeh

Cursus bekijken

Oefeninstructies

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

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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)
Code bewerken en uitvoeren