79351062

Date: 2025-01-13 02:30:11
Score: 1
Natty:
Report link

TLDR: Just change your .sum() in plot_collisions_bar() to .sum(numeric_only=True)

For details, the modified plot_collisions_bar() is listed below:

@app.callback(Output("graph", "figure"),
              [Input("date picker", "start_date"),
               Input("date picker", "end_date"),])
def plot_collisions_bar(start_date, end_date):
    fig = px.bar(
        (collisions
         .loc[collisions["DATE"].between(start_date, end_date)]
         .groupby("BOROUGH", as_index=False)
         .sum(numeric_only=True)   # <<< Change here
        )
        ,
        x="COLLISIONS",
        y="BOROUGH",
        title=f"Traffic Acci[![enter image description here][1]][1]dents in NYC between {start_date[:10]} and {end_date[:10]}"
    )
    return fig
Reasons:
  • Blacklisted phrase (1): enter image description here
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: drxaero