Reloading submodules in IPython

IPython comes with some automatic reloading magic: %load_ext autoreload %autoreload 2 It will reload all changed modules every time before executing a new line. The way this works is slightly different than dreload. Some caveats apply, type %autoreload? to see what can go wrong. If you want to always enable this settings, modify your IPython … Read more

How to display pandas DataFrame of floats using a format string for columns?

import pandas as pd pd.options.display.float_format=”${:,.2f}”.format df = pd.DataFrame([123.4567, 234.5678, 345.6789, 456.7890], index=[‘foo’,’bar’,’baz’,’quux’], columns=[‘cost’]) print(df) yields cost foo $123.46 bar $234.57 baz $345.68 quux $456.79 but this only works if you want every float to be formatted with a dollar sign. Otherwise, if you want dollar formatting for some floats only, then I think you’ll have … Read more

Using both Python 2.x and Python 3.x in IPython Notebook

The idea here is to install multiple ipython kernels. Here are instructions for anaconda. If you are not using anaconda, I recently added instructions using pure virtualenvs. Anaconda >= 4.1.0 Since version 4.1.0, anaconda includes a special package nb_conda_kernels that detects conda environments with notebook kernels and automatically registers them. This makes using a new … Read more

IPython Notebook locale error [duplicate]

I summarize here the solution to be found on: http://blog.lobraun.de/2009/04/11/mercurial-on-mac-os-x-valueerror-unknown-locale-utf-8/ I added these lines to my .bash_profile: export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 I reloaded the profile: source ~/.bash_profile I then ran ipython again: ipython notebook Changing locales The above will work for the English language in a US locale. One may want different settings. At the … Read more