Shelter adoption bars added up again from September to the end of the year

Write code · Medium · §10.3 Date axes and range exploration

The table shelters holds the monthly adoptions at two animal shelters, East and West, in 2026. Using a condition on the date column (date), pick only the rows from September to December, add up the adoptions again for each shelter, and draw a bar chart with px.bar() with the shelter (shelter) on the x-axis and that total (adoptions) on the y-axis.

Do not split the bar colors, and use the title Adoptions from September to December. Show the figure with fig.show(). Grading changes the adoption counts and draws the chart again.

Target figure for Shelter adoption bars added up again from September to the end of the year
Target figure

Starter code

import pandas as pd
import plotly.express as px

dates = pd.date_range("2026-01-01", periods=12, freq="MS")
shelters = pd.DataFrame({
    "date": list(dates) * 2,
    "shelter": ["East"] * 12 + ["West"] * 12,
    "adoptions": [14, 12, 18, 20, 22, 25, 19, 17, 21, 24, 30, 35, 10, 11, 15, 13, 18, 20, 23, 22, 16, 19, 27, 29],
})

# Write your code here

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.