Loading 100k values in a dash dropdown

Viewed 31

I'm trying to load 100K tickers in a Dropdown. Yet when I do that I have an error loading layout message when loading the page.

from os.path import abspath, dirname
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import os
from ..server import app

PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
DATA_PATH = os.path.join(PROJECT_ROOT, '../data/')
df = pd.read_csv(DATA_PATH + 'tickers_september_2017_red.csv')

""" Test entities """
df.rename(columns={'Ticker': 'value', 'Name': 'label'}, inplace=True)
stock1 = df.to_dict('index')
# stock1 = {"label": "Microsoft", "value": "msft"}

STOCK_LIST = stock1

base_dir = dirname(dirname(abspath(__file__)))

server = app.server


def layout():
    return html.Div([
        html.Div([
            html.Div([
                dcc.Dropdown(
                    id='select-stock',
                    options=STOCK_LIST.items(),
                    value=STOCK_LIST[0].get('label')
                )
            ])
        ], className='pretty_container twelve columns')
    ], className='pretty_container twelve columns')

if __name__ == "__main__":
    app.run_server(debug=False, port=8051)

I guess this is because there are to many values. Maybe I can reduce the number of suggested values? Should I rather opt for querying a database?

0 Answers
Related