Right off the top of my head, I think the biggest problems are the module-level objects being created and accessed directly.
Regardless of what you do here, you’re going to have some degree of a race condition existing within your system. (See my comment at Matplotlib in Django "Starting a Matplotlib GUI outside of the main thread..." - #5 by KenWhitesell)
About the best / safest solution I can think of would be to set up an external worker to process these requests, making sure the data components are initialized at the beginning of each request. (It might even be better / easier to launch a separate process to do this on each request. That way you can ensure that there’s no “global state” to be concerned about.)
But the bottom line is that I don’t expect that you’re going to find a clean way of doing this directly “in-line” as you’re trying to do here. Those components (pandas and matplotlib) are not particularly “friendly” to the Django environment.