Notes on Ipython Notebook

Project management

Let’s look at what notebook is good at:

And notebook becomes a pain when:

Therefore, some rules of thumb for reasonabily use notebooks for a research project:

Execute shell command

Instead of calling “os.system” which hides the call back of the command, the clean way should be:

cmd = 'ls -lrt'  ## The shell command you wish to execute
callback = ! $cmd

## Or simply
callback = ! ls -lrt

## If the command is to run another python script
$cmd = ' arg1 arg2'
callback = %run $cmd 


When running some block of code that takes a long time, we wish to redirect the log to a file. This preserves the full log even if we close the notebook before the code finishes. The clean way to do this is still under investigation.

Table display

Two clean and concise ways to checkout the data in your table:

from IPython.display import display

## The panda table you wish to visualize
table = pandas.DataFrame(mat,columns=['col1','col2'])  

## This will show the beginning and the end of your table

## This will show the beginning of your table