Selection of tables

I would like to have a selection from the tables that are available in my notebook in my dropdown. So I want to be able to select my table in the drop-down menu. Does anybody know of any similar example that can help to do it?

Thank you very much in advance!

Hi,

You can use a dictionary for that. One very short example:

import plotly.express as px

df_dict = {
    "iris": px.data.iris(),
    "gapminder": px.data.gapminder()
}

# ....
dcc.Dropdown(
    id="data-sel",
    options=df_dict.keys()
)

# and to select it
@callback(
     #....,
     Input("data-sel", "value")
)
def update_table(df_key):
     df = df_dict[df_key]
     # ....

Hope this helps!

1 Like