High to low prices by region
Now you know how to sort a DataFrame, the estate agents have asked you to create a bar plot visualizing the average property price by region from largest to smallest.
regions has been created by grouping melb by region and calculating the average price, and preloaded for you:
regions = melb.groupby("region", as_index=False)["price"].mean()
Este ejercicio forma parte del curso
Interactive Data Visualization with Bokeh
Instrucciones del ejercicio
- Sort
regionsby price in descending order. - Create the figure, setting
x_rangeequal to the"region"column ofregionsand labeling the x- and y-axes as"Region"and"Sales", respectively. - Add bar glyphs from
regions, showing thepriceon the y-axis against eachregionon the x-axis, and setting the width to0.9 - Update the y-axis format to display in millions of dollars with 1 decimal place.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Sort df by price in descending order
regions = regions.____("____", ascending=____)
# Create figure
fig = figure(x_range=____, x_axis_label=____, y_axis_label=____)
# Add bar glyphs
fig.vbar(x=____, top=____, width=____)
# Format the y-axis to numeric format
fig.____[____].____ = ____(____="$0.0a")
output_file(filename="sorted_barplot.html")
show(fig)