ipython-notebook

How to recover deleted iPython Notebooks

血红的双手。 提交于 2019-11-27 19:20:00
问题 I have iPython Notebook through Anaconda. I accidentally deleted an important notebook, and I can't seem to find it in trash (I don't think iPy Notebooks go to the trash). Does anyone know how I can recover the notebook? I am using Mac OS X. Thanks! 回答1: This is bit of additional info on the answer by Thuener, I did the following to recover my deleted .ipynb file. The cache is in ~/.cache/chromium/Default/Cache/ (I use chromium) used grep in binary search mode, grep -a 'import math' (replace

How to export an IPython notebook to HTML for a blog post?

廉价感情. 提交于 2019-11-27 18:59:25
What is the best way to get an ipython notebook into html format for use in a blog post? It is easy to turn an ipython notebook into a PDF, but I'd rather publish as an html notebook. I've found that if I download the notebook as a .ipynb file, then load it onto gist, then look at it with the ipython notebook viewer (nbviewer.ipython.org), THEN grab the html source, I can paste it into a blog post (or just load it as html anywhere) and it looks about right. However, if I use the "print view" option directly from ipython, the source contains a bunch of javascript rather than the processed html,

How to change font in ipython notebook

心不动则不痛 提交于 2019-11-27 17:37:14
I am fairly new to python and have no html experience. The question has been asked and either not answered at all or not answered in enough detail for me to set the default font within iPython (not change to browser). Specifically, what has to be put in the css file and which css file should be used? I am on a Windows system. For reference, these are in answer to the linked SO questions below: in #1 : an unnamed file in /usr/lib/python2.6/.../css/ in comment to #1 : change monospace font in browser - worked but font is italic in #2 : custom.css in profile subdirectory /static/custom/custom.css

ipython notebook clear cell output in code

♀尐吖头ヾ 提交于 2019-11-27 17:19:13
In a iPython notebook, I have a while loop that listens to a Serial port and print the received data in real time. What I want to achieve to only show the latest received data (i.e only one line showing the most recent data. no scrolling in the cell output area) What I need(i think) is to clear the old cell output when I receives new data, and then prints the new data. I am wondering how can I clear old data programmatically ? cel You can use IPython.display.clear_output to clear the output of a cell. from IPython.display import clear_output for i in range(10): clear_output() print("Hello

Format certain floating dataframe columns into percentage in pandas

好久不见. 提交于 2019-11-27 17:17:36
I am trying to write a paper in IPython notebook, but encountered some issues with display format. Say I have following dataframe df , is there any way to format var1 and var2 into 2 digit decimals and var3 into percentages. var1 var2 var3 id 0 1.458315 1.500092 -0.005709 1 1.576704 1.608445 -0.005122 2 1.629253 1.652577 -0.004754 3 1.669331 1.685456 -0.003525 4 1.705139 1.712096 -0.003134 5 1.740447 1.741961 -0.001223 6 1.775980 1.770801 -0.001723 7 1.812037 1.799327 -0.002013 8 1.853130 1.822982 -0.001396 9 1.943985 1.868401 0.005732 The numbers inside are not multiplied by 100, e.g. -0.0057

Draw graph in NetworkX

时光总嘲笑我的痴心妄想 提交于 2019-11-27 17:12:03
问题 I'm trying to draw any graph in NetworkX, but get nothing, not even errors: import networkx as nx import matplotlib.pyplot as plt g1=nx.petersen_graph() nx.draw(g1) 回答1: Add to the end: plt.show() import networkx as nx import matplotlib.pyplot as plt g1 = nx.petersen_graph() nx.draw(g1) plt.show() When run from an interactive shell where plt.ion() has been called, the plt.show() is not needed. This is probably why it is omitted in a lot of examples. If you run these commands from a script

Simple way to measure cell execution time in ipython notebook

拈花ヽ惹草 提交于 2019-11-27 16:58:42
I would like to get the time spent on the cell execution in addition to the original output from cell. To this end, I tried %%timeit -r1 -n1 but it doesn't expose the variable defined within cell. %%time works for cell which only contains 1 statement. In[1]: %%time 1 CPU times: user 4 µs, sys: 0 ns, total: 4 µs Wall time: 5.96 µs Out[1]: 1 In[2]: %%time # Notice there is no out result in this case. x = 1 x CPU times: user 3 µs, sys: 0 ns, total: 3 µs Wall time: 5.96 µs What's the best way to do it? Update I have been using Execute Time in Nbextension for quite some time now. It is great. Use

How do I comment out multiple lines in Jupyter Ipython notebook? [closed]

喜你入骨 提交于 2019-11-27 16:48:42
I want to comment out a block of multiple lines in Jupyter (Ipython Notebook), but can't find out how to do that in this current version. It used to be in one of the drop down menus but is no longer there. How do you comment out multi-line blocks of code at once? This is not a duplicate because the solution given in the following link doesn't seem to work anymore: How can I block comment code in the IPython notebook? Ctrl + / does nothing. user5036413 Ctrl + / works for me in Chrome browser in MS Windows. On a Mac, use Cmd + / (thanks Anton K). Please note, if / did not work out of the box,

Is it possible to host nbviewer locally?

情到浓时终转凉″ 提交于 2019-11-27 16:44:20
问题 I want to bring nbviewer to my job. Because I am not able to share company data (place it on github), I will need to install nbviewer locally. There are instructions to set one up on Heroku but this will not work for me. Has anyone attempted this? Is it even worth the effort? Any other alternatives? Thanks. Steps to get nbviewer running on your local machine: Step1: Download nbviewer from github Step2: Download nbconvert from github Step3: Place nbconvert contents into the "nbconvert" folder

Per-cell output for threaded IPython Notebooks

冷暖自知 提交于 2019-11-27 15:19:53
问题 I don't want to raise this as an issue, because it seems like a completely unreasonable feature request for what is a fairly amazing tool. But if any readers happen to be familiar with the architecture I'd be interested to know if a potential extension seems feasible. I recently wrote a notebook with some simple threaded code in it, just to see what would happen when I ran it. The notebook code (tl;dr it starts a number of parallel threads that print in a sleep loop) is available at https:/