ipython

Clear output widget using onclick Button event - Python

我的未来我决定 提交于 2020-01-22 02:21:12
问题 I am working on a Jupyter Notebook in which I am using a button created with ipywidgets to display a df when clicking on it. For this I am using the following code: import ipywidgets as widgets import numpy as np vartest = 0 Button = widgets.Button(description='Search', disabled=False, button_style='info', tooltip='Search') display(Button) def whenclick2(b): global df if vartest==0: df = pd.DataFrame(np.arange(5)) class displayDF(object): def _create_widgets(self): self.button = Button self

How do I define custom magics in jupyter?

ぃ、小莉子 提交于 2020-01-21 09:27:17
问题 I'm using Ubuntu 14.04 LTS with an Anaconda python installation: Python 3.5.1 :: Anaconda 2.4.1 (64-bit) I'm trying to use this recipe to enable C++ interactive compiling in my ipython notebooks: import IPython.core.magic as ipym @ipym.magics_class class CppMagics(ipym.Magics): @ipym.cell_magic def cpp(self, line, cell=None): """Compile, execute C++ code, and return the standard output.""" # Define the source and executable filenames. source_filename = 'temp.cpp' program_filename = 'temp.exe'

passing x- and y-data as keyword arguments in matplotlib?

寵の児 提交于 2020-01-21 05:04:05
问题 Or, why doesn't import numpy import matplotlib.pyplot as plt plt.plot(xdata = numpy.array([1]), ydata = numpy.array(1), color = 'red', marker = 'o') work? c.f. > In [21]: import numpy > In [22]: import matplotlib.pyplot as plt > In [23]: plt.plot(xdata = numpy.array([1]), ydata = numpy.array(1), color = 'red', marker = 'o') > Out[23]: [] > In [24]: plt.plot([1],[1], color = 'red', marker = 'o') > Out[24]: [<matplotlib.lines.Line2D at 0x108036890>] > In [25]: plt.plot(1, 1, color = 'red',

Compiling Python 2.6.6 and need for external packages wxPython, setuptools, etc… in Ubuntu

耗尽温柔 提交于 2020-01-20 07:13:41
问题 I compiled Python 2.6.6 with google-perf tools (tcmalloc) library to eliminate some of the memory issues I was having with the default 2.6.5. After getting 2.6.6 going it seems to not work becuase I think having issues with the default 2.6.5 install in Ubuntu. Will none of the binaries installed from the software channel like wxPython and setuptools work properly with 2.6.6. Do these need to be recompiled? Any other suggestions to get it working smoothly. Can I still set 2.6.5 as default

Compiling Python 2.6.6 and need for external packages wxPython, setuptools, etc… in Ubuntu

独自空忆成欢 提交于 2020-01-20 07:13:26
问题 I compiled Python 2.6.6 with google-perf tools (tcmalloc) library to eliminate some of the memory issues I was having with the default 2.6.5. After getting 2.6.6 going it seems to not work becuase I think having issues with the default 2.6.5 install in Ubuntu. Will none of the binaries installed from the software channel like wxPython and setuptools work properly with 2.6.6. Do these need to be recompiled? Any other suggestions to get it working smoothly. Can I still set 2.6.5 as default

Display multiple images in one IPython Notebook cell?

自古美人都是妖i 提交于 2020-01-19 18:24:13
问题 If I have multiple images (loaded as NumPy arrays) how can I display the in one IPython Notebook cell? I know that I can use plt.imshow(ima) to display one image… but I want to show more than one at a time. I have tried: for ima in images: display(Image(ima)) But I just get a broken image link: 回答1: Short answer: call plt.figure() to create new figures if you want more than one in a cell: for ima in images: plt.figure() plt.imshow(ima) But to clarify the confusion with Image : IPython.display

Strange module auto complete behavior in IPython

强颜欢笑 提交于 2020-01-17 08:34:13
问题 See what I mean? At first it showed only RB and absolute_import as choices. STILL I was able to import Gtk . After that it showed a couple of more options. Still isn't a complete list of modules. If I import some other module (which I know of from the docs), then it appears in the list. (I posted a similar problem previously but I wasn't able to explain it sufficiently well so I'm posting it again with better details) 回答1: Autocompletion try to determine the possible value of what you ask. gi

Interactive Python - solutions for relative imports

心不动则不痛 提交于 2020-01-17 04:41:24
问题 From Python relative imports for the billionth time: For a from .. import to work, the module's name must have at least as many dots as there are in the import statement. ... if you run the interpreter interactively ... the name of that interactive session is __main__ Thus you cannot do relative imports directly from an interactive session I like to use interactive Jupyter Notebook sessions to explore data and test modules before writing production code. To make things clear and accessible to

How to plot in a new window in Spyder-IDE(Python)

孤者浪人 提交于 2020-01-16 17:51:25
问题 My Spyder-IDE prints the plots in it's ipython console . How can I change the settings to do plotting on a new pop-up window? 回答1: You need to go to the menu Tools > Preferences > IPython console > Graphics > Graphics Backend and select the option called Automatic there. After doing that you need to restart either Spyder or the console kernel for this change to take effect. 来源: https://stackoverflow.com/questions/54840619/how-to-plot-in-a-new-window-in-spyder-idepython

Double the size of images output from ob-ipython

偶尔善良 提交于 2020-01-16 16:49:09
问题 I am using ob-ipython on org-mode, which positions the images from matpllotlib automatically. However, the images it output is quite small. search through the source code and did not find keywords of 'pic' or 'img'. https://github.com/gregsexton/ob-ipython How could double the size of images? 回答1: This is a matplotlib setting. #+BEGIN_SRC ipython :session :results raw drawer %matplotlib inline import matplotlib.pyplot as plt import numpy as np plt.rcParams['figure.figsize'] = [12, 8] #+END