ipython-magic

Share data between IPython Notebooks

会有一股神秘感。 提交于 2019-11-27 05:33:20
问题 If I have several IPython notebooks running on the same server. Is there any way to share data between them? For example, importing a variable from another notebook? Thanks! 回答1: This works for me : The %store command lets you pass variables between two different notebooks. data = 'this is the string I want to pass to different notebook' %store data Now, in a new notebook… %store -r data print(data) this is the string I want to pass to different notebook I've successfully tested with sklearn

Using magic commands outside of Interactive Shell in IPython

随声附和 提交于 2019-11-27 03:33:54
问题 Is there a way to use "magic commands" from IPython from an outside file? For example if I have a file, "rcode.py" with the code: %load_ext rmagic %R a=c(1,2,3);b=c(2,3,4);print(summary(lm(a~b))) This gives me a SyntaxError for the first line when I run it using ipython rcode.py in the command line. However when I type these lines straight into the interactive shell with ipython it runs fine. Is this because you only do magic in the interactive shell? Thanks! 回答1: If you name your file with a