ipython-notebook

Turn off auto-closing parentheses in ipython

给你一囗甜甜゛ 提交于 2019-12-02 16:03:36
I stay up-to-date with ipython's dev branch (because ipython is pretty much the most awesome thing ever). Fairly recently (before yesterday's awesome ipython 2.0 release) I noticed that it has started to automatically close parentheses, brackets, quotes, etc., as I type them. It happens in both terminal [nothing else I use in terminal does it] and notebook sessions, so I assume it was an intentional choice on the part of the developers. I can respect that other people might like this feature, but it drives me completely nuts . I can't find any option for it in the configuration files. I can't

How can I play a local video in my IPython notebook?

我只是一个虾纸丫 提交于 2019-12-02 15:51:06
I've got a local video file (an .avi, but could be converted) that I would like to show a client (ie it is private and can't be published to the web), but I can't figure out how to play it in IPython notebook. After a little Googling it seems that maybe the HTML5 video tag is the way to go, but I don't know any html and can't get it to play. Any thoughts on how I can embed this? Viktor Kerkez ( updated 2019, removed unnecessarily costly method ) Just do: from IPython.display import Video Video("test.mp4") Or if you want to use the HTML element: from IPython.display import HTML HTML(""" <video

How does one change color in markdown cells ipython/jupyter notebook?

自闭症网瘾萝莉.ら 提交于 2019-12-02 15:41:54
I'm only looking to format a specific string within a cell. I change that cell's format to "Markdown" but I'm not sure how to change text color of a single word. I don't want to change the look of the whole notebook (via a CSS file). You can simply use raw html tags like foo <font color='red'>bar</font> foo Be aware that this will not survive a conversion of the notebook to latex. As there are some complaints about the deprecation of the proposed solution. They are totally valid and Scott has already answered the question with a more recent, i.e. CSS based approach. Nevertheless, this answer

View pdf image in an iPython Notebook

谁说我不能喝 提交于 2019-12-02 15:29:28
The following code allows me to view a png image in an iPython notebook. Is there a way to view pdf image? I don't need to use IPython.display necessarily. I am looking for a way to print a pdf image in a file to the iPython notebook output cell. ## This is for an `png` image from IPython.display import Image fig = Image(filename=('./temp/my_plot.png')) fig Thank you. The problem you (and others) face is that PDFs cannot be displayed directly in the browser. The only possible way to get something similar is to use an image-converter to create a PNG or JPG out of the PDF and display this one.

Can I access python variables within a `%%bash` or `%%script` ipython notebook cell?

≯℡__Kan透↙ 提交于 2019-12-02 14:36:44
Is there a way to access variables in the current python kernel from within a %%bash or other %%script cell? Perhaps as command line arguments or environment variable(s)? Python variables can be accessed in the first line of a %%bash or %%script cell, and so can be passed as command line parameters to the script. For example, with bash you can do this: %%bash -s "$myPythonVar" "$myOtherVar" echo "This bash script knows about $1 and $2" The -s command line option allows you to pass positional parameters to bash, accessed through $n for the n-th positional parameter. Note that what's actually

Module Successfully Installed, but Not Found in IPython

左心房为你撑大大i 提交于 2019-12-02 07:50:37
I have installed the package bigfloat and the MPFR and GMP libraries. When I run python in the terminal (I use a Mac), bigfloat can be imported and works successfully. However, I typically write my scripts in iPython Notebook. When I try to import bigfloat here, it says 'module not found.' I have installed other packages such as SciPy, and using print scipy. file I see that it is located at //anaconda/lib/python2.7/site-packages/scipy/ init .pyc I'm not sure of how to check where bigfloat is located. From reading other peoples' installation issues, I am thinking that there might be more than

ValueError: index must be monotonic increasing or decreasing

青春壹個敷衍的年華 提交于 2019-12-02 07:12:40
ser3 = Series(['USA','Mexico','Canada'],index = ['0','5','10']) here ranger = range(15) I get an error while using Forward fill in iPython ser3.reindex(ranger,method = 'ffill') /Users/varun/anaconda/lib/python2.7/site-packages/pandas/core/index.pyc in _searchsorted_monotonic(self, label, side) 2395 return len(self) - pos 2396 -> 2397 raise ValueError('index must be monotonic increasing or decreasing') 2398 2399 def get_slice_bound(self, label, side, kind): ValueError: index must be monotonic increasing or decreasing As David said it was due to index being a string. But why were you getting the

Execute another ipython notebook in a separate namespace

主宰稳场 提交于 2019-12-02 07:11:15
问题 I've been using some very nice code from this example to run one ipython notebook from another, which I (basically) copy below. This turns out to be a very nice way to organize my code. But now, I want to compare some sympy expressions that I've coded up with roughly equivalent sympy expressions that someone else has coded up. And since there are some name clashes, I'd like to be able to execute the two notebooks in their own namespaces, so that if Bob and I both define a sympy expression x ,

Trying to create grouped variable in python

 ̄綄美尐妖づ 提交于 2019-12-02 06:46:05
I have a column of age values that I need to convert to age ranges of 18-29, 30-39, 40-49, 50-59, 60-69, and 70+: For an example of some of the data in df 'file', I have: and would like to get to: I tried the following: file['agerange'] = file[['age']].apply(lambda x: "18-29" if (x[0] > 16 or x[0] < 30) else "other") I would prefer not to just do a groupby since the bucket sizes aren't uniform but I'd be open to that as a solution if it works. Thanks in advance! It looks like you are using the Pandas library. They include a function for doing this: http://pandas.pydata.org/pandas-docs/version

Stdout in IPython notebook vs CLI IPython

六月ゝ 毕业季﹏ 提交于 2019-12-02 06:39:08
问题 Results of commands are not displayed when run from a notebook cell. From IPython notebook: os.system("pwd") 0 <-- no errors From IPython invoked from CLI: In [15]: os.system("pwd") /Users/joe Out[15]: 0 <-- no errors I expected to see /Users/joe displayed when command runs from a notebook cell. What's missing? Thank you, I. 回答1: This is explained here: When you do os.system, it's not capturing stdout/stderr from the new process. In the terminal, this works, because stdout and stderr just go