ipython-notebook

Change resolution of imshow in ipython

五迷三道 提交于 2019-12-18 19:06:25
问题 I am using ipython, with a code that looks like this: image = zeros(MAX_X, MAX_Y) # do something complicated to get the pixel values... # pixel values are now in [0, 1]. imshow(image) However, the resulting image always has the same resolution, around (250x250). I thought that the image's dimensions would be (MAX_X x MAX_Y), but that is seemingly not the case. How can I make ipython give me an image with a greater resolution? 回答1: The height and width of the displayed image on the screen is

Make ipython notebook print in real time

末鹿安然 提交于 2019-12-18 14:05:44
问题 Ipython Notebook doesn't seem to print results in real time, but seems to buffer in a certain way and then bulk output the prints. How can I make ipython print my results as soon as the print command is processed? Example code: import time def printer(): for i in range(100): time.sleep(5) print i Supposing that the above code is in a file that is imported. How could I make it that when I call the printer function it prints a number every 5 seconds and not all the numbers at the very end?

What is the pure Python equivalent to the IPython magic function call %matplotlib inline?

爷,独闯天下 提交于 2019-12-18 12:38:14
问题 In IPython Notebook, I defined a function that contains a call to the magic function %matplotlib , like this: def foo(x): %matplotlib inline # ... some useful stuff happens in between here imshow(np.asarray(img)) I'd like to put that function into a Python module so that I can just import and call it. However, to do this, I'd need to remove the %matplotlib inline from my code and replace it with its pure-Python equivalent. What is the pure-Python equivalent? 回答1: %matplotlib inline directly

pandas dataframe as latex or html table nbconvert

淺唱寂寞╮ 提交于 2019-12-18 11:44:25
问题 Is it possible to get a nicely formatted table from a pandas dataframe in ipython notebook when using nbconvert to latex & PDF? The default seems to be just a left-aligned block of numbers in a shoddy looking font. I would like to have something more like the html display of dataframes in the notebook, or a latex table. Saving and displaying a .png image of an HTML rendered dataframe would also be fine, but how exactly to do that has proved elusive. Minimally, I would just like a simple

Make more than one chart in same IPython Notebook cell

萝らか妹 提交于 2019-12-18 10:19:31
问题 I have started my IPython Notebook with ipython notebook --pylab inline This is my code in one cell df['korisnika'].plot() df['osiguranika'].plot() This is working fine, it will draw two lines, but on the same chart. I would like to draw each line on a separate chart. And it would be great if the charts would be next to each other, not one after the other. I know that I can put the second line in the next cell, and then I would get two charts. But I would like the charts close to each other,

Make more than one chart in same IPython Notebook cell

邮差的信 提交于 2019-12-18 10:19:12
问题 I have started my IPython Notebook with ipython notebook --pylab inline This is my code in one cell df['korisnika'].plot() df['osiguranika'].plot() This is working fine, it will draw two lines, but on the same chart. I would like to draw each line on a separate chart. And it would be great if the charts would be next to each other, not one after the other. I know that I can put the second line in the next cell, and then I would get two charts. But I would like the charts close to each other,

collapse cell in jupyter notebook

浪子不回头ぞ 提交于 2019-12-18 09:59:48
问题 I am using ipython Jupyter notebook. Let's say I defined a function that occupies a lot of space on my screen. Is there a way to collapse the cell? I want the function to remain executed and callable, yet I want to hide / collapse the cell in order to better visualize the notebook. How can I do this? 回答1: The jupyter contrib nbextensions Python package contains a code-folding extension that can be enabled within the notebook. Follow the link (Github) for documentation. To install using

old sklearn version in Jupyter Notebook

两盒软妹~` 提交于 2019-12-18 09:44:13
问题 I update sklearn version by terminal with conda install scikit-learn=0.18 if I list with conda list scikit-learn # packages in environment at /Users/Claudia/anaconda: scikit-learn 0.18.1 np111py27_1 scikit-learn 0.18.1 <pip> but if I run in notebook print('The scikit-learn version is {}.'.format(sklearn.__version__)) the result is The scikit-learn version is 0.17.1. How can I solve and update also the version in Jupyter Notebook? 回答1: to update the version used by Jupyter you need to open

merge two dataframes without repeats pandas

蹲街弑〆低调 提交于 2019-12-18 09:29:41
问题 I am trying to merge two dataframes, one with columns: customerId, full name, and emails and the other dataframe with columns: customerId, amount, and date. I want to have the first dataframe be the main dataframe and the other dataframe information be included but only if the customerIds match up; I tried doing: merge = pd.merge(df, df2, on='customerId', how='left') but the dataframe that is produced contains a lot of repeats and looks wrong: customerId full name emails amount date 0

secondary_y=True changes x axis in pandas

我是研究僧i 提交于 2019-12-18 07:15:14
问题 I'm trying to plot two series together in Pandas, from different dataframes. Both their axis are datetime objects, so they can be plotted together: amazon_prices.Close.plot() data[amazon].BULL_MINUS_BEAR.resample("W").plot() plt.plot() Yields: All fine, but I need the green graph to have its own scale. So I use the amazon_prices.Close.plot() data[amazon].BULL_MINUS_BEAR.resample("W").plot(secondary_y=True) plt.plot() This secondary_y creates a problem, as instead of having the desired graph,