Update df using callback

I am building a dash app where I ask the user to select a currency for eg(usd, eur, gbp)
I added a toggle input in my layout for taking the user input.
Now if the user selects EUR I want the values in my df to be updated.
I wrote a callback function which takes the id of the toggle buttons as input but I am not sure what should be my Output as I can’t have a callback without an output component in Dash.
Please guide me how can I update my global df using a callback?

The dash extensions module has NoOutputTransform, which allows for callbacks without an output component.

However, updating a global df is probably a bad idea anyways, at least if multiple people will use your app at the same time. See “Why global variables will break your app” for details.

I assume you want to display the updated values somewhere in your app. If so, a better approach would be to set that as the Output component of your callback, make a local copy of your df in the callback and change that as needed.

1 Like

@MichelH Thank you for explaining this :slightly_smiling_face: