Learn how to use Dash Bio for next-gen sequencing & quality control. 🧬 Register for the Oct 27 webinar.

How to create a dropdown from a pandas dataframe column

In the example below: https://plotly.com/python/dropdowns/#restyle-dropdown

The layout is created with a dictionary where every label is written one by one. But what if I import a database form a dynamic dataframe that changes its internal items every time?

In the following dataframe, every label is manually input. If I had a column in a dataframe with 30 inputs and I want the dropdown to be generated with every value of the column as a label. How can I do it?

fig.update_layout(
    updatemenus=[
        dict(
            buttons=list([
                dict(
                    args=["type", "surface"],
                    label="3D Surface",
                    method="restyle"
                ),
                dict(
                    args=["type", "heatmap"],
                    label="Heatmap",
                    method="restyle"
                )
            ]),
            direction="down",
            pad={"r": 10, "t": 10},
            showactive=True,
            x=0.1,
            xanchor="left",
            y=1.1,
            yanchor="top"
        ),
    ]
)