How to use the results and variables of one notebook Jupyter in another?

Asked

Viewed 469 times

0

Suppose there is a Jupyter notebook called notebook1.ipynb where several variables are calculated with interesting results. Suppose, then, as part of another analysis in another notebook called notebook2.ipynb, it is interesting to access the variables calculated in notebook1. In this case, how to access these same variables and results without having to copy the entire code?

1 answer

0


Jupyter owns a magic command called %run that allows you to call and execute another external code from inside the notebook that is running, thus keeping its results and variables.

Ex:

Being in the notebook2.ipynb, you can execute the command below:

%run "./notebook1.ipynb"

Jupyter will then execute the notebook1 from within the notebook on which you are running this command and with it will load into memory all the calculated variables and show all the results that are normally shown in notebook1.

  • Please, can someone with the necessary score add the "jupyter" tag to me in this question? I don’t have enough points to well note down that question. Thank you so much already.

  • Anderson, you can even do this by clicking on the link edit which falls below the question.

  • He wants to create the tag. I already say that the mobile site is not possible.

  • Yes, the tag needs to be created. In fact, there is one that is the ipython-notebook that I used that today makes no sense since the project evolved and became the Jupyter project that includes kernels other than that of Ipython, as well as Ijulia, and others. So creating the right tag would be important.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.