IPython Notebooks are a web server-based interactive environment that combine Python code execution, text, mathematics, plots, and rich media into a single document, along with automatic persistence of code and an easy means of deploying code to the Web. You can find more details on the IPython Notebook site at http://ipython.org/notebook.html.
IPython Notebooks are an exceptional way to learn both Python and pandas. This book will neither assume the use of IPython Notebooks, nor teach their usage beyond the brief examples given in this section. However, the code provided with the book are IPython Notebook files, so demonstrating how to run the server provided by Anaconda is worth a few paragraphs of explanation.
The IPython Notebook server can be started with the following shell command (the same on all platforms):
ipython notebook
You will get a small amount of output on the console:
elheydt/.ipython/profile_default' 2014-12-06 21:36:11.547 [NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js 2014-12-06 21:36:11.570 [NotebookApp] Serving notebooks from local directory: /Users/michaelheydt 2014-12-06 21:36:11.570 [NotebookApp] 0 active kernels 2014-12-06 21:36:11.570 [NotebookApp] The IPython Notebook is running at: http://localhost:8888/ 2014-12-06 21:36:11.570 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Then, a browser window that looks similar to the following screenshot will open:
The default notebook shows the contents of the folder where the command was executed. Clicking on the New Notebook button will present you with a notebook where you can start entering your pandas code. The following screenshot shows the IPython Notebook where we will enter the pandas code:
Within the input box, enter the three lines of code from the earlier example and then press Shift + Enter to run the code in that block. The server will execute the code and return the output to the browser:
Additionally, after a brief period of time, the code will be saved automatically (you can save explicitly by clicking on the Save button). Returning to the home page, you will see the notebook created in the folder.
Clicking on the notebook's link will take you back to the notebook for additional editing and execution.
3.145.179.35