ipython

Is it possible to display pandas styles in the IPython console?

我只是一个虾纸丫 提交于 2019-12-11 15:08:20
问题 Is it possible to display pandas styles in an iPython console? The following code in a Jupyter notebook import pandas as pd import numpy as np np.random.seed(24) df = pd.DataFrame({'A': np.linspace(1, 10, 5)}) df = pd.concat([df, pd.DataFrame(np.random.randn(5, 1), columns=list('B'))], axis=1) df.style.format({'B': "{:.2%}"}) correctly produces In the console I only get In [294]: df.style.format({'B': "{:.2%}"}) Out[294]: <pandas.io.formats.style.Styler at 0x22f3f4fe780> Is it possible to

Unable to install IHaskel kernel into Jupyter: “could not parse version number”

六月ゝ 毕业季﹏ 提交于 2019-12-11 13:16:56
问题 I've recently completed the installation instructions for Haskell, and have reached the final step where I run ihaskell install to install the IHaskell kernel into Jupyter. However at this point I'm stuck, with the error Detected IPython, but could not parse version number. ihaskell: Ran commands: which ipython /usr/local/bin/ipython --version which /usr/local/bin/ipython Exception: ExitFailure 1 which makes no sense, since when I run those commands myself, I get a valid (and required)

Jupyter notebook, ImportError: No module named pylab

爷,独闯天下 提交于 2019-12-11 13:16:52
问题 I am a ubuntu user, and I have install python 2.7.9 on my computer. In order to use jupyter notebook, I down load anaconda2. After my installation, I find after entering the command 'jupyter notebook', my browser will open jupyter notebook, but I can't find new python2, so I went to the https://ipython.readthedocs.org/en/latest/install/kernel_install.html Use the following commands: conda create -n ipykernel_py2 python=2 ipykernel source activate ipykernel_py2 python -m ipykernel install -

Incorrect behaviour of print() when executed from within a QTDialog window in Spyder

孤街醉人 提交于 2019-12-11 12:48:54
问题 I am working on a very simple interface to explore/graph csv files. My aim is ultimately to explore, not to build software as I am not a developer, more of a "desperate user" :-) I am leveraging the code found in this example These are my first steps both in Python and in GUI, so I tend to put print messages in my calls so that I can more or less track what is happening. And this is where I found a strange behavior if I run the code from within Spyder. import sys import os from PyQt4 import

How to quickly create a IPython shell in Emacs?

烈酒焚心 提交于 2019-12-11 12:47:14
问题 When I do python development in emacs, I want an IPython shell available. Here is my current way of accomplishing this: M-x ansi-term Which prompts me with Run program: /bin/bash , which I replace with /usr/bin/ipython It's often the case that I want another terminal in emacs, perhaps to run the app, so I do: M-x rename-buffer and change the name of the buffer to ipython so that I can change buffers easily, with having to remember which terminal was the IPython shell. It seems that there

The stdout/stderr in python notebooks

前提是你 提交于 2019-12-11 12:16:30
问题 I'm using python 3 and recently I was able to interface a FORTRAN solver for some type of optimization problems (thanks to eryksun here on stack overflow). The little issue that is getting on the way is that the solver output in the python notebook (jupyter) does not show up. Note that the solver returns the right solution, but it doesn't display its progress nor any mesages. Although, if call the same FORTRAN solver from a julia notebook, I can see the output in the julia notebook. The

IPython - importing/populating namespace with custom magic

北战南征 提交于 2019-12-11 11:27:22
问题 The %pylab magic in IPython imports a bunch of functions into the user's workspace, which is very convenient. Looking at the code, it's not at all obvious how this is done. What I have so far is a magic function in my startup folder: from IPython.core.magic import register_line_magic @register_line_magic def import_my_functions(line): """ Import functions into namespace somehow.... e.g. import numpy as np """ It then should be possible: In[1]: %import_my_functions imported the following:

iPython + pylab/matplotlib animations hang

廉价感情. 提交于 2019-12-11 11:17:43
问题 I cannot for the life of me get iPython to show an animated plot. This code is taken directly from the matplotlib animation examples, and it works fine using plain old python (aka python animate.py ). import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation fig, ax = plt.subplots() line, = ax.plot(np.random.rand(10)) ax.set_ylim(0, 1) def update(data): line.set_ydata(data) return line, def data_gen(): while True: yield np.random.rand(10) ani = animation

Can only zip with RDD which has the same number of partitions error

匆匆过客 提交于 2019-12-11 11:07:17
问题 I have a ipython notebook which has pyspark code and it works fine on my machine but when I try to run it on a different machine it throws error at this line (rdd3 line): rdd2 = sc.parallelize(list1) rdd3 = rdd1.zip(rdd2).map(lambda ((x1,x2,x3,x4), y): (y,x2, x3, x4)) list = rdd3.collect() The error I get is: ValueError Traceback (most recent call last) <ipython-input-7-9daab52fc089> in <module>() ---> 16 rdd3 = rdd1.zip(rdd2).map(lambda ((x1,x2,x3,x4), y): (y,x2, x3, x4)) /usr/local/bin

How to print return value of method in Python?

廉价感情. 提交于 2019-12-11 09:47:22
问题 class Queue(): def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def Enqueue(self,item): return self.items.insert(0, item) def Size(self): return len(self.items) def Dequeue(self): return self.items.pop() Q = Queue() def Hotpot(namelist,num): for name in namelist: Q.Enqueue(name) while Q.Size() > 1: for i in range(num): Q.Enqueue(Q.Dequeue()) Q.Dequeue() return Q.Dequeue() # I would like to print and see what is getting removed, I tried with x = Q.Dequeue(), print