ipython-notebook

matplotlib and libpng issues with ipython notebook

你离开我真会死。 提交于 2019-11-30 08:23:01
问题 I was trying to use ipython notebook . I installed all the dependency libraries. However, I cannot use either the "--pylab=inline" option when launching ipython or "savefig" function in the Ipython console. When I tried to do either of them, an error message was returned "RuntimeError: Could not create write struct" resulting from execution of matplotlib. Also, a warning from the notebookApp prompt said "libpng warning: Application built with libpng-1.2.41 but running with 1.5.13". However, I

Download CSV from an iPython Notebook

谁说我不能喝 提交于 2019-11-30 08:13:53
I run an iPython Notebook server, and would like users to be able to download a pandas dataframe as a csv file so that they can use it in their own environment. There's no personal data, so if the solution involves writing the file at the server (which I can do) and then downloading that file, I'd be happy with that. Coen Jonker How about using the FileLinks class from IPython? I use this to provide access to data directly from Jupyter notebooks. Assuming your data is in pandas dataframe p_df: from IPython.display import FileLink, FileLinks p_df.to_csv('/path/to/data.csv', index=False) p_df.to

Insert a link inside a pandas table

让人想犯罪 __ 提交于 2019-11-30 08:08:34
I'd like to insert a link (to a web page) inside a pandas table, so when it is displayed in ipython notebook, I could press the link. I tried the following: In [1]: import pandas as pd In [2]: df = pd.DataFrame(range(5), columns=['a']) In [3]: df['b'] = df['a'].apply(lambda x: 'http://example.com/{0}'.format(x)) In [4]: df Out[4]: a b 0 0 http://example.com/0 1 1 http://example.com/1 2 2 http://example.com/2 3 3 http://example.com/3 4 4 http://example.com/4 but the url is just displayed as text. I also tried using ipython HTML object: In [5]: from IPython.display import HTML In [6]: df['b'] =

How to start an ipython shell(not notebook) within a conda or virtualenv

六眼飞鱼酱① 提交于 2019-11-30 05:59:53
问题 Is it possible to start an ipython shell(in terminal) within a conda or virtualenv ? The ipython shell should belongs to the respective environment. I know a way to start jupyter notebook within the env, by creating a kernelspecs for the virtual env and then choosing the env kernel within the jupyter notebook. here is the link : http://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs But this only setup the jupyter notebook for the current environment. Is there a to do the same for

pandas dataframe as latex or html table nbconvert

不打扰是莪最后的温柔 提交于 2019-11-30 05:26:14
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 centre-aligned table in a nice font. I haven't had any luck with various attempts to use the .to_latex()

How to check that pylab backend of matplotlib runs inline?

↘锁芯ラ 提交于 2019-11-30 05:10:44
I am modifying a python module that plots some special graphs using matplotlib. Right now, this module just saves all figures as files. I would like to make it possible to import the module while working in ipython notebook and see the results "inline", on the other hand I would like to keep the default functionality of saving the figures as files when the module is imported in all other cases. So I need somehow to check if the module is imported in ipython notebook and the pylab is operating inline or not. How can I check this? You can check the matplotlib backend with: import matplotlib

Unable to run unittest's main function in ipython/jupyter notebook

眉间皱痕 提交于 2019-11-30 05:01:58
I am giving an example which throws an error in ipython/jupyter notebook, but runs fine as an individual script. import unittest class Samples(unittest.TestCase): def testToPow(self): pow3 = 3**3 assert pow3==27 if __name__ == '__main__': unittest.main() The error is below: --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-7-232db94ae8b2> in <module>() 8 9 if __name__ == '__main__': ---> 10 unittest.main() /usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest

Dynamically changing dropdowns in IPython notebook widgets and Spyre

北慕城南 提交于 2019-11-30 05:00:55
I have a dropdown in an IPython notebook (as part of the HTML widgets) and in a Spyre app (as a dropdown element), say to pick a continent and I'd like to add a second dropdown to select the country within the continent. Now obviously the options within the second dropdown are dependent on the value of the first one. I'm struggling to find a convenient way to have a callback function that would update this UI element. I have almost done this in the IPython notebook where I had one interact function and within the called function, I'd create a second interact element with the second dropdown.

How to clear an IPython Notebook's output in all cells from the Linux terminal?

て烟熏妆下的殇ゞ 提交于 2019-11-30 04:27:18
I have a problem when the output from a notebook is really long and it's saved into the notebook, any time I want to open this particular notebook again the browser crashes and can't display correctly. To fix this I have to open it with a text editor and delete all output from that cell causing the problem. I wonder if there is a way to clean all output from the notebook so one can open it again without problem. I want to delete all output since deleting a specific one seems more troublesome. --ClearOutputPreprocessor.enabled=True There is now a built-in command line option to do it: jupyter

Open an ipython notebook via double-click on osx

余生长醉 提交于 2019-11-30 03:45:24
I've downloaded a couple of ipython notebooks, and I'd like to open them in browser tabs without navigating to the directory I've downloaded them to and running ipython notebook notebook_name.ipynb . I realize this probably means I'm lazy, but it seems like a common use case to me. Am I missing something obvious? Use Pineapple application for opening and working on your IPython/Jupyter notebooks. It is pretty cool. Update: Now there is nteract , which is a new jupyter-like Desktop app. After installing it, make it the default app for opening .ipynb files. Then just double-click any notebook to