It is not safe to use global variables in dash. Instead, I recommend storing the df inside a hidden div inside the layout and using that hidden div as its own Input in the remaining callback functions.
For more information, see:
- Using a hidden div: Add reactive expressions / blocks · Issue #49 · plotly/dash · GitHub
- Why
globalvariables aren’t safe: App not resetting with page refresh - #7 by chriddyp