Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Output content of second column using drop down selection of first column

$
0
0

@deebratforlife wrote:

Please Help awesome people! i am new to Dash and trying my best to figure it all out.

I need to use a drop down where I select a state (example: California) and output a statement saying your selection is California and Number of Solar Plants are 289 (which is column 2 of the table).

Here is my code until now:

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

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/solar.csv')
available_indicators = df['State'].unique()

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

app.layout = html.Div([
    dcc.Dropdown(id='my-dropdown',
       options=[{'label': i, 'value': i} for i in available_indicators],
       value='Texas'),
     html.Div(id='dd-output-container'),
])

@app.callback(
    dash.dependencies.Output('dd-output-container', 'children'),
    [dash.dependencies.Input('my-dropdown', 'value')])
def update_output(value):
    return 'You have selected "{}"'.format(value)

if __name__ == '__main__':
    app.run_server(debug=True)

Kindly suggest. I will keep trying too in the meantime. Thanks!

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles