ipython

How can I select every cell in an ipython notebook?

删除回忆录丶 提交于 2020-01-13 03:12:37
问题 This would be useful because I often want to use the builtin "Find and Replace" tool on every cell in the notebook; because this tool only works on selected cells (which, usually, is just the "current" cell), it would be useful if I could quickly select all of them. To be clear, I want to select the cells in " command mode "; I'm not talking about highlighting all the text. On my laptop, Cmd+A just highlights all the text. Maybe some random plugin can do the trick? 回答1: You can get the "Find

tab complete dictionary keys in ipython

只愿长相守 提交于 2020-01-12 14:18:08
问题 I was wondering if anybody knows how to enable or implement tab completion for dictionary keys in IPython? It seems like it wouldn't be very different from functionality that already exists, like tab completion of object attributes. If I'm wrong, then I'd like to understand why 回答1: IPython supports dict key completion for string keys since version 3.0.0 (despite not appearing in release notes), thanks to this patch. It also supports column name completion for numpy struct arrays and pandas

Fastest way to iterate through a pandas dataframe?

陌路散爱 提交于 2020-01-12 08:28:10
问题 How do I run through a dataframe and return only the rows which meet a certain condition? This condition has to be tested on previous rows and columns. For example: #1 #2 #3 #4 1/1/1999 4 2 4 5 1/2/1999 5 2 3 3 1/3/1999 5 2 3 8 1/4/1999 6 4 2 6 1/5/1999 8 3 4 7 1/6/1999 3 2 3 8 1/7/1999 1 3 4 1 I could like to test a few conditions for each row and if all conditions are passed I would like to append the row to list. For example: for row in dataframe: if [row-1, column 0] + [row-2, column 3] >

Export individual cell in IPython/Jupyter notebook

对着背影说爱祢 提交于 2020-01-12 04:52:08
问题 I am able to export the entire notebook as HTML, but I would like to export just a single cell, together with its output. Is there some way of doing this? 回答1: One way to do this is to use a custom preprocessor. I explain how to do this briefly in response to Simple way to choose which cells to run in ipython notebook during run all. To summarize: you can extend nbconvert.preprocessors.ExecutePreprocessor to create a preprocessor that checks cell metadata to determine whether that cell should

Using Ipython ipywidget to create a variable?

寵の児 提交于 2020-01-12 04:38:29
问题 This seems really simple but I have not been able to find a single example or to solve this myself. How do I use an ipywidget widget to create or return a python variable/object, such as a list or string, that can be used in a following cell? 回答1: There is a good introduction to ipywidgets at http://blog.dominodatalab.com/interactive-dashboards-in-jupyter/ which answers this question. You need two widgets, one for input, and another to bind the value of that input. Here's an example for text

ipython: how to set terminal width

这一生的挚爱 提交于 2020-01-11 20:59:02
问题 When I use ipython terminal and want to print a numpy.ndarray which has many columns, the lines are automatically broken somewhere around 80 characters (i.e. the width of the lines is cca 80 chars): z = zeros((2,20)) print z Presumably, ipython expects that my terminal has 80 columns. In fact however, my terminal has width of 176 characters and I would like to use the full width. I have tried changing the following parameter, but this has no effect: c.PlainTextFormatter.max_width = 160 How

ipython: how to set terminal width

人盡茶涼 提交于 2020-01-11 20:56:49
问题 When I use ipython terminal and want to print a numpy.ndarray which has many columns, the lines are automatically broken somewhere around 80 characters (i.e. the width of the lines is cca 80 chars): z = zeros((2,20)) print z Presumably, ipython expects that my terminal has 80 columns. In fact however, my terminal has width of 176 characters and I would like to use the full width. I have tried changing the following parameter, but this has no effect: c.PlainTextFormatter.max_width = 160 How

ipython: how to set terminal width

社会主义新天地 提交于 2020-01-11 20:56:05
问题 When I use ipython terminal and want to print a numpy.ndarray which has many columns, the lines are automatically broken somewhere around 80 characters (i.e. the width of the lines is cca 80 chars): z = zeros((2,20)) print z Presumably, ipython expects that my terminal has 80 columns. In fact however, my terminal has width of 176 characters and I would like to use the full width. I have tried changing the following parameter, but this has no effect: c.PlainTextFormatter.max_width = 160 How

Mac下安装ipython与jupyter

♀尐吖头ヾ 提交于 2020-01-11 15:32:54
Mac下安装ipython与jupyter IPython从Python发展而来,更倾向于科学计算。互联网数据分析更喜欢用。 首先切换root用户: sudo su - pip3自动安装ipython MacBook-Pro:~ root# pip3 install ipython 自动安装完成后建立软连接,方便使用 MacBook-Pro:bin root# ln -s /Library/Frameworks/Python.framework/Versions/3.6/bin/ipython /usr/local/bin/ 成功安装,执行使用 MacBook-Pro:bin root# ipython Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) Type 'copyright', 'credits' or 'license' for more information IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help. In [1]: name = 'tiger' In [2]: name Out[2]: 'tiger' In [3]: 安装jupyter notebook 1.激活虚拟环境venv 2. pip3 install

Use IPython magic functions in ipdb shell

不想你离开。 提交于 2020-01-11 15:27:13
问题 When debugging Python script using ipdb my_script.py , I want to use IPython magic functions like %paste , %cd in ipdb debug session shell. Is is possible and how? 回答1: According to the ipdb Github repo magic IPython functions are not available. Fortunately, the IPython debugger provides a couple of clues of how to get this functionality without launching a separate IPython shell. Here is what I did to run %cpaste : ipdb> from IPython import get_ipython ipdb> shell = get_ipython() ipdb> shell