ipython-notebook

How to enable timing magics for every cell in Jupyter notebook?

梦想与她 提交于 2019-12-07 10:31:35
问题 The %%time and %%timeit magics enable timing of a single cell in a Jupyter or iPython notebook. Is there similar functionality to turn timing on and off for every cell in a Jupyter notebook? This question is related but does not have an answer to the more general question posed of enabling a given magic automatically in every cell. 回答1: A hacky way to do this is via a custom.js file (usually placed in ~/.jupyter/custom/custom.js ) The example of how to create buttons for the toolbar is

Customize welcome page of ipython notebook

允我心安 提交于 2019-12-07 09:27:59
问题 Can I customize the landing page of an iPython notebook server (version 2.3)? I mean that, at the starting page (something like: http://localhost:8888/tree ), I'd like to display Welcome to the i[Py] Notebook of John Doe or modify the existing banner.. Is this possible? 回答1: You can change the banner logo or replace it with a text using your custom.css. Custom Title To simply change the text add the following lines #ipython_notebook::before{content:"Welcome to my notebook"} #ipython_notebook

IPython notebook to slides: Reveal is not defined

坚强是说给别人听的谎言 提交于 2019-12-07 07:22:39
问题 I'm using nbconvert to make a reveal.js slideshow from my notebook. Specifically, I'm running: ipython nbconvert --to slides analysis.ipynb . This creates "analysis.slides.html", and I put "reveal.js" in the same folder. That is, I have: reveal.js ... analysis.ipynb analysis.slides.html However, when opening "analysis.slides.html" in the browser JavaScript console, I get the following: analysis.slides.html:1992 Uncaught ReferenceError: Reveal is not defined analysis.slides.html:2032 Uncaught

Unicode in ipython notebook

南笙酒味 提交于 2019-12-07 06:30:39
问题 I'm trying to get a "degree" sign (°) in a matplotlib plot from ipython notebook. When I run ax = plt.gca() ax.set_xlabel("something at 55" + unicode("\xc2", errors='replace')) ax.plot([0.,1.,], [0.,1.]) I get a plot, but instead of the degree sign, I have a strange black square with a question mark. This also happens when I try to savefig the figure to PDF. If I try to run ax = plt.gca() ax.set_xlabel("something at 55°") ax.plot([0.,1.,], [0.,1.]) I get an error (see below). Any idea what I

Jupyter notebook kernel dies when creating dummy variables with pandas

心已入冬 提交于 2019-12-07 06:27:01
问题 I am working on the Walmart Kaggle competition and I'm trying to create a dummy column of of the "FinelineNumber" column. For context, df.shape returns (647054, 7) . I am trying to make a dummy column for df['FinelineNumber'] , which has 5,196 unique values. The results should be a dataframe of shape (647054, 5196) , which I then plan to concat to the original dataframe. Nearly every time I run fineline_dummies = pd.get_dummies(df['FinelineNumber'], prefix='fl') , I get the following error

Convert SVG to png or other?

不想你离开。 提交于 2019-12-07 05:36:12
问题 Since it's very easy to display the content of a SVG file inside the iPython notebook, is there also a way (easy too) to get what we see inside a png file or other ? from IPython.display import SVG SVG(filename='../images/python_logo.svg') If I do svg = SVG(filename='../images/python_logo.svg') How can I save it to a png file ? 回答1: SVG are vectors images (the drawings are saved as commands to draw lines, circles, etc). PNGs are bitmaps. So to convert SVG to PNG, you need a renderer. The most

Executing Javascript cells in Jupyter Notebooks

寵の児 提交于 2019-12-07 04:08:23
问题 I'm seeing some strange behavior using Javascript cells in a (trusted) Jupyter notebook. For example, I can execute the following cells, intended to fetch the current URL of the notebook. %%javascript var kernel = IPython.notebook.kernel; var thename = window.location.href; var command = "notebook_url = " + "'"+thename+"'"; kernel.execute(command); And now I try to access the variable in another cell: print notebook_url This works as expected with I run the cells one after another (Shift +

Disable Jupyter Keyboard Shortcuts

我们两清 提交于 2019-12-07 03:38:49
问题 One of my Jupyter notebooks uses an html <input> tag that expects typed user input, but whenever I type in the text box, command mode keyboard shortcuts activate. Is it possible to turn off keyboard shortcuts for a single cell or notebook? 回答1: You could copy paste this line into your custom.js: $([IPython.events]).on("app_initialized.NotebookApp", function () { ... // Starting from this line, replace 'Shift-k' with whatever // shortcut you're trying to remove. IPython.keyboard_manager

ImportError: No module named 'cv2' using jupyter

戏子无情 提交于 2019-12-07 01:58:19
问题 I am trying to import OpenCV into my ipynb using Jupyter. I kept getting : ImportError: No module named 'cv2' import cv2 import pandas as pd import numpy as np import matplotlib from matplotlib import pyplot as plt import seaborn as sns Any idea how to import cv2 in jupyter? 回答1: If you have already installed opencv, then its possible that your notebook and your opencv library are in 2 different python environments. The following has helped me in the past: Open your notebook In an new cell

Cannot get python3 in Jupyter notebook

北慕城南 提交于 2019-12-07 01:52:33
问题 How can I get python3 to run in Jupyter? I cannot get it to supply that kernel as well. When I run ipython3 notebook at the terminal, I check the version of Python: import sys print(sys.version) where I get the output: 3.4.0 (default, Jun 19 2015, 14:20:21) [GCC 4.8.2] When I run jupyter notebook , I have only the option of a new python 2 notebook and import sys print(sys.version) where I get the output: 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] I try to run: sudo ipython3 kernelspec