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

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 on another notebook called notebook2.ipynb , it is interesting to access the variables computed in notebook1 . In that case, how do you access those same variables and results without having to copy all the code?

    
asked by anonymous 20.09.2018 / 00:49

1 answer

0

Jupyter has a magic command called % run that allows you to call and execute another external code from within the running notebook, thus saving your results and variables .

Ex:

While in notebook2.ipynb , you can run the command below:

%run "./notebook1.ipynb"

Jupyter will then run the notebook1 from within the notebook on which you are running this command and thus will load all calculated variables into memory and display all the results that are normally shown in < strong> notebook1 .

    
20.09.2018 / 00:49