BaşlayınÜcretsiz Başlayın

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()

Bu egzersiz

Interactive Data Visualization with Bokeh

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Sort regions by price in descending order.
  • Create the figure, setting x_range equal to the "region" column of regions and labeling the x- and y-axes as "Region" and "Sales", respectively.
  • Add bar glyphs from regions, showing the price on the y-axis against each region on the x-axis, and setting the width to 0.9
  • Update the y-axis format to display in millions of dollars with 1 decimal place.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# 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)
Kodu Düzenle ve Çalıştır