ipython

Import of matlab.engine works in IPython but not in Jupyter

被刻印的时光 ゝ 提交于 2019-12-19 11:52:19
问题 I just installed the MATLAB Engine API for Python to my home directory using $ python setup.py build --build-base=$HOME install --prefix=$HOME However, when I try to import matlab.engine from a Jupyter notebook, I get the following error: --------------------------------------------------------------------------- EnvironmentError Traceback (most recent call last) <ipython-input-2-833daa01cd46> in <module>() 8 import numpy as np 9 import matplotlib.pyplot as plt ---> 10 import matlab.engine 11

Trying to create grouped variable in python

China☆狼群 提交于 2019-12-19 11:42:47
问题 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! 回答1: It looks like you are

How do I set up default cell magics for every ipython notebook cell?

家住魔仙堡 提交于 2019-12-19 10:28:10
问题 I have an iPython notebook that is completely made up of R cells. At the start of every cell, I have defined my R cell magic as follows: %%R However, is there a way to have just set that as a default for the entire notebook, so I don't have to type it into every cell? 回答1: IRKernel is an R kernel for ipython/jupyter as suggested by @cel. There are lots of other kernels that you can use. 来源: https://stackoverflow.com/questions/30490801/how-do-i-set-up-default-cell-magics-for-every-ipython

Imbed matplotlib figure into iPython HTML

瘦欲@ 提交于 2019-12-19 10:12:37
问题 I want to dynamically write and display HTML with a code cell in Jupyter Notebook. The objective is to generate the HTML to display table, div, img tags in some way I choose. I want to capture img data and place it where I want in this auto generated HTML. So far I've figured out that I can do the following: from IPython.core.display import HTML HTML("<h1>Hello</h1>") and get: Hello That's great. However, I want to be able to do this: HTML("<h1>Hello</h1><hr/><img src='somestring'/>") and get

ImportError: dynamic module does not define module export function (PyInit_cv2)

心已入冬 提交于 2019-12-19 07:35:07
问题 When I try to import cv2 in IPython , I am getting this error- ImportError: dynamic module does not define module export function (PyInit_cv2) I have opencv 3.0, ubuntu 14.04, python 3.4. I searched online but couldn't get any answer. 回答1: Python3 libraries usually can be found in: /usr/lib/python3/dist-packages I found out that the library cv2.cpython-34m.so is needed for Python3.4. But this file wasn't be contained in my default library directory. In my environment, this library was stored

IPython - single line spacing possible?

隐身守侯 提交于 2019-12-19 05:51:20
问题 By default, the IPython shell shows a blank line between inputs: In [1]: 1 + 1 Out[1]: 2 In [2]: import math In [3]: math.sqrt(2) Out[3]: 1.4142135623730951 In [4]: Is there any way to configure the IPython shell so that it does not produce a blank line between each command history? This would significantly increase the amount of history I would be able to see on my screen. 回答1: I'm working on Windows, Alok's excerp didn't differ from the default content of these three lines in my

pandas dataframe hexbin plot has no xlabel or axis values

ⅰ亾dé卋堺 提交于 2019-12-19 05:19:51
问题 I am trying to plot a dataframe as hexbin but can't seem to get the xlabel and x-axis values to plot. The dataframe is as follows: szen_df.xs('left', level='pos') and the plot is as follows: szen_df.xs('left', level='pos').plot(x='szen', y='lat', xlim=(0,90), ylim=(-90,90), kind='hexbin', colormap='Reds' ) with result: 回答1: I'm seeing this problem as well with python 2.7, pandas 0.16.2.dev, and ipython version 3.1.0. Looking to the documentation for pandas.DataFrame.plot, the only reference

IPython Notebook Tab-Complete — Show Docstring

社会主义新天地 提交于 2019-12-19 05:12:42
问题 I just upgraded to IPython 2.0.0 and the behavior of tab-complete seems to have changed for the worse. (Using pyreadline 2.0, which according to this question might matter). Formerly, if I hit TAB after function_name( , IPython would show the docstring for that function. Now, I just see a dropdown list of what I guess is everything in the namespace, including: Error types names of other notebooks in the directory IPython magic functions Other functions I've defined etc. The old behavior was

Real-time output from engines in IPython parallel?

丶灬走出姿态 提交于 2019-12-19 04:14:40
问题 I am running a bunch of long-running tasks with IPython's great parallelization functionality. How can I get real-time output from the ipengines' stdout in my IPython client? E.g., I'm running dview.map_async(fun, lots_of_args) and fun prints to stdout. I would like to see the outputs as they are happening. I know about AsyncResult.display_output() , but it's only available after all tasks have finished. 回答1: You can see stdout in the meantime by accessing AsyncResult.stdout , which will

conda error: could not found url

≯℡__Kan透↙ 提交于 2019-12-19 03:21:27
问题 recently i installed the anaconda but when i'm open it i got this error: Error fetching package index Could not find URL: https://pypi.python.org/pypi/osx-64/ also when i'm using the command conda install ... i got Using Anaconda Cloud api site https://api.anaconda.org Fetching package metadata: .....Error: Could not find URL: https://pypi.python.org/pypi/osx-64/ . and i cant install packages. and this is conda info : platform : osx-64 conda version : 3.19.1 conda-build version : 1.19.0