Change IPython/Jupyter notebook working directory

jupyter notebook –help-all could be of help: –notebook-dir=<Unicode> (NotebookManager.notebook_dir) Default: u’/Users/me/ipynbs’ The directory to use for notebooks. For example: jupyter notebook –notebook-dir=/Users/yourname/folder1/folder2/ You can of course set it in your profiles if needed, you might need to escape backslash in Windows. Note that this will override whatever path you might have set in a jupyter_notebook_config.py … Read more

How to run an IPython magic from a script (or timing a Python script)

It depends a bit on which version of IPython you have. If you have 1.x: from IPython import get_ipython ipython = get_ipython() If you have an older version: import IPython.core.ipapi ipython = IPython.core.ipapi.get() or import IPython.ipapi ipython = IPython.ipapi.get() Once that’s done, run a magic command like this: ipython.magic(“timeit abs(-42)”) Note that the script must … Read more

In which conda environment is Jupyter executing?

As mentioned in the comments, conda support for jupyter notebooks is needed to switch kernels. Seems like this support is now available through conda itself (rather than relying on pip). http://docs.continuum.io/anaconda/user-guide/tasks/use-jupyter-notebook-extensions/ conda install nb_conda which brings three other handy extensions in addition to Notebook Conda Kernels.

Matplotlib and Ipython-notebook: Displaying exactly the figure that will be saved

As noted by @andrew, the ipython magics are enforcing bbox_inches=”tight” by default. This can be overridden using other magics as explained in the ipython documentation: %matplotlib inline %config InlineBackend.print_figure_kwargs = {‘bbox_inches’:None} produces an inline image identical to that produced by savefig.

Progress indicator during pandas operations

Due to popular demand, I’ve added pandas support in tqdm (pip install “tqdm>=4.9.0”). Unlike the other answers, this will not noticeably slow pandas down — here’s an example for DataFrameGroupBy.progress_apply: import pandas as pd import numpy as np from tqdm import tqdm # from tqdm.auto import tqdm # for notebooks # Create new `pandas` methods … Read more

How to embed HTML into IPython output?

This seems to work for me: from IPython.core.display import display, HTML display(HTML(‘<h1>Hello, world!</h1>’)) The trick is to wrap it in display as well. Source: http://python.6.x6.nabble.com/Printing-HTML-within-IPython-Notebook-IPython-specific-prettyprint-tp5016624p5016631.html Edit: from IPython.display import display, HTML In order to avoid: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython 7.14, please import from IPython display

How to run an .ipynb Jupyter Notebook from terminal?

nbconvert allows you to run notebooks with the –execute flag: jupyter nbconvert –execute <notebook> If you want to run a notebook and produce a new notebook, you can add –to notebook: jupyter nbconvert –execute –to notebook <notebook> Or if you want to replace the existing notebook with the new output: jupyter nbconvert –execute –to notebook … Read more