Let say I have two jupyter notebook files called: main and sub
Here are my needs:
- Call and run
subfrommain - Each notebook has its own variables space. For example, if
x=1inmain, butx=2insubunless exchange info - I can pass certain variables to
suband retrieve certain variables fromsub(not all) ← This is very important as I do not want variables to overlap and mess up the code
I have been trying all days with GPT and Copilot looking for an effective solution but:
- Using
%run -i% orIPython.get_ipython` will just share all variables between the two notebooks - Using
nbclients→ both GPT and Copilot keep giving wrong answers (i.e. I still cannot pass and receive variables fromsubtomain)
I know there is another solution is create a defined fucntion on .py file; however since my work at the moment is complex to convert from ipynb file to py file
If anyone have any suggestions, I would really appreciate (a sample code would be x2 appreciate)
Thank you!
user24758287if you cannot make a minimal discussable example it makes it hard to discuss things commonly used with Jupyter and Python that you may be missing. Just a general guide, if it is too bing to put in one Jupyter.ipynbfile then you should probably be using Python more and not relying on only.ipynbfiles. You can always use the.ipynbto mine data you make in scripts or other notebooks but alas without details we are waving out hands. Are you using pickling,%storeto exchange data? Are you using Papermill or Jupytext?%runand%storeis a great way to solve my need