ipython

name 'get_config' is not defined

▼魔方 西西 提交于 2019-12-09 02:36:52
问题 when i am working with ipython notebook, i want to run a notebook server. I followed the official tutorial However, when I want to obtain the get_config() function as said in the tutorial, I come across with the name get_config is not defined problem. I searched the internet and found the page . However, there is no ~/.ipython/profile_default/ipython_config.py file in my ubuntu 12.04 system. What can I do to solve the problem? 回答1: Paul Ivanov stated in the forum post: get_config is available

Pipe Ipython magic output to a variable?

痴心易碎 提交于 2019-12-09 02:10:28
问题 I want to run a bash script in my ipython Notebook and save the output as a string in a python variable for further manipulation. Basically I want to pipe the output of the bash magic to a variable, For example the output of something like this: %%bash some_command [options] foo bar 回答1: What about using this: myvar = !some_command --option1 --option2 foo bar instead of the %%bash magic? Using the ! symbol runs the following command as a shell command, and the results are all stored in myvar

Getting NameError with Django 1.5 and IPython

左心房为你撑大大i 提交于 2019-12-09 00:38:02
问题 I'm running Django 1.5.1, Python 2.7.2, and IPython 0.13.2. If I do "python ./manage.py shell" from within my Django project directory, I get the following error: from django import forms class CommentForm(forms.Form): name = forms.CharField() NameError: name 'forms' is not defined. I know forms is defined as I can see it when it do "dir(forms)". I've noticed that this error only occurs when I'm running iPython within the REPL. If I start the REPL and only use the plain, old Python

Change the Emacs “send code to interpreter” C-c C-r command in IPython-mode

强颜欢笑 提交于 2019-12-09 00:06:16
问题 The question here is related (but NOT identical) and complementary to Change the "send code to interpreter" (C-c |) command in python-mode . I work on a Mac 10.9.5, Emacs 24.4, Python 2.7.8 and IPython 2.2.0. My idea is to change the C-c C-r emacs command to send a region/line of code in IPython mode to C-RET , as when using R. This is because I usually work with R, but from now on, I am going to be using R and Python (IPython in particular, which I really like), and C-RET --already the send

How to reuse plot in next jupyter cell [duplicate]

馋奶兔 提交于 2019-12-08 19:53:13
问题 This question already has an answer here : How do I show the same matplotlib figure several times in a single IPython notebook? (1 answer) Closed 2 years ago . I have a jupyter notebook and wish to create a plot in one cell, then write some markdown to explain it in the next, then set the limits and plot again in the next. This is my code so far: # %% %matplotlib inline import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 2 * np.pi) y = np.sin(x ** 2) plt.plot(x, y); # %%

How do you make NLTK draw() trees that are inline in iPython/Jupyter

六月ゝ 毕业季﹏ 提交于 2019-12-08 19:14:25
问题 For Matplotlib plots in iPython/Jupyter you can make the notebook plot plots inline with %matplotlib inline How can one do the same for NLTK draw() for trees? Here is the documentation http://www.nltk.org/api/nltk.draw.html 回答1: Based on this answer: import os from IPython.display import Image, display from nltk.draw import TreeWidget from nltk.draw.util import CanvasFrame def jupyter_draw_nltk_tree(tree): cf = CanvasFrame() tc = TreeWidget(cf.canvas(), tree) tc['node_font'] = 'arial 13 bold'

plotting a sphere in python for an orbital trajectory

本小妞迷上赌 提交于 2019-12-08 18:35:33
How can I put a sphere of radius 1737 at the location of (384400,0,0) ? This sphere would be the moon in my trajectory. Everything else with the code is fine, I just don't know how to add a sphere in that location with that radius. import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D me = 5.974 * 10 ** (24) # mass of the earth mm = 7.348 * 10 ** (22) # mass of the moon G = 6.67259 * 10 ** (-20) # gravitational parameter re = 6378.0 # radius of the earth in km rm = 1737.0 # radius of the moon in km r12 = 384400.0 #

How can i split 'Date' column into 'Date' and 'Time' column? [closed]

こ雲淡風輕ζ 提交于 2019-12-08 18:23:30
Closed . This question needs details or clarity . It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post . Closed 2 years ago . In the image shown, how can i split 'Date' column into 'Date' and 'Time' column? ' You can use str.split by whitespace what is default separator: df = pd.DataFrame({'Date':['4/1/2016 0.00','4/2/2016 0.05']}) print (df) Date 0 4/1/2016 0.00 1 4/2/2016 0.05 df[['Date','Time']] = df.Date.str.split(expand=True) print (df) Date Time 0 4/1/2016 0.00 1 4/2/2016 0.05 来源: https://stackoverflow.com

unable to open jupyter(ipython) notebook on browser

无人久伴 提交于 2019-12-08 17:28:17
问题 I'm using python3.5 and jupyter 4.0.6 . I launched the jupyter notebook , and get the following output: [I 21:47:27.021 NotebookApp] Serving notebooks from local directory: /home/nitrous [I 21:47:27.021 NotebookApp] 0 active kernels [I 21:47:27.021 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/ [I 21:47:27.022 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [W 21:47:27.023 NotebookApp] No web browser found: could

IPython: quickly dump the output of a cell to file

拜拜、爱过 提交于 2019-12-08 17:11:34
问题 It is very easy to save an ipython notebook cell or several cells to a file or to pastebin. But sometimes I want to dump the output of some operation to file. What's the fast way of doing that? %save output Out[56] gives me: Out[56] is neither a string nor a macro. And if I do: %save output str(Out[56]) It works but I lose the pretty-print formatting, and have an automatic .py extension added to the output file name. 回答1: to keep pretty-print formatting try %save output repr(_56) if an object