Please review how to ask for help in the post Getting good answers to your questions .
My guess is that your issue isn’t a Jupyter question and that if you ran this code as a basic Python script, you’d have the same issues. However, it is hard to tell if it is pertinent to this forum or not because you shared your large code block as an image that cannot be used by anyone who would attempt to test or evaluate your code. One thing that would help, even if you end up seeking help in a more general or module-specific location, is if you learn how to share notebooks and code using https://gist.github.com/ or Github and then provide the link to that. There are other places where you can easily share snippets of code even without registering, such as Pastebin. If your code block was somewhat smaller, I’d encourage you to paste it directly into this forum using what is described in the section ’ Block code formatting’ here.
If the code comes from somewhere else, then point those who could help you at the source as a way to provide them the code.
Include any information about what to expect if it does run correctly.