Making a dashboard!

import pandas as pd
import plotly.express as px
import plotly.graph_objects as go

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

from flask import Flask
app = Flask(name)

app = dash.Dash(name)

df = pd.read_csv(r’C:\Users\devak.spyder-py3\intro_bees.csv’)

df = df.groupby([‘State’, ‘ANSI’, ‘Affected by’, ‘Year’, ‘state_code’])[[‘Pct of Colonies Impacted’]].mean()

df.reset_index(inplace = True)

print(df[:5])

app.layout = html.Div([

html.H1("Web Application Dashboards with Dash",
        style = {'text-aling' : 'center'}),

dcc.Dropdown(id = "slct_year", 
             options = [
                 {"label" : "2015", "value" : 2015},
                 {"label" : "2016", "value" : 2016},
                 {"label" : "2017", "value" : 2017},
                 {"label" : "2018", "value" : 2018}],
                 multi = False,
                 value = 2015,
                 style = {'width' : "40%"}),

html.Div(id = 'output_container', children = []),
html.Br(),

dcc.Graph(id = 'my_bee_map', figure = {})])

@app.callback(
[Output(component_id = ‘out_container’,
component_property = ‘children’),

 Output(component_id = 'my_bee_map',
        component_property = 'figure')],

[Input(component_id = 'slct_year',
       component_property = 'value')])

def update_graph(option_slctd):
print(option_slctd)
print(type(option_slctd))

container = "The year chosen by user was:{}".format(option_slctd)

dff = df.copy()
dff = dff[dff["Year"] == option_slctd]
dff = dff[dff["Affected by"] == "varroa_mites"]



fig = px.choropleth(
    data_frame = dff,
    locationmode = 'USA-states',
    locations = 'state-code', 
    scope = "usa",
    color = 'Pct of Colonies Impacted',
    hover_data = ['State', 'Pct of Colonies Impacted'],
    color_continuous_scale = px.colors.sequential.Yl0rRd,
    labels = {'Pct of Colonies Impacted' : '% of Bee Colonies'},
    template = 'plotly_dark')

return container, fig

if name == ‘main’:
app.run_server(debug = False)

When writing this code I get this…!

Dash is running on http://127.0.0.1:8050/

  • Serving Flask app “coding for dash” (lazy loading)
  • Environment: production
    WARNING: This is a development server. Do not use it in a production deployment.
    Use a production WSGI server instead.
  • Debug mode: off
  • Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)

Pls, help me I am trying to find the answer to the problem for many days…!!!

And, Welcome!

Thank you for your help!
By The Way, I study in class 8