Python Tutorials
Step 1: Install Python
In order to follow along any of the tutorials included here, you need to have a working version of python (at least 2.7). We use the Anaconda version of python and the
steps for installation are included below.
Python Installation Basics
To follow along during the tutorial, you will need to do the following :
Download and install the Anaconda python distribution: http://continuum.io/downloads
On Mac and Linux, include the path to the Anaconda bin directory in your .bashrc file.
export PATH=
"<path_to_anaconda_bin>:$PATH"
If Anaconda is installed in /home/johndoe/anaconda, then
this
will be:
export PATH=
"/home/johndoe/anaconda/bin:$PATH"
- On Windows, it should appear in the Start Menu as soon as Anaconda is installed. You can also access the binaries from the command prompt.
Helpful links on Anaconda, ipython notebooks etc:
http://docs.continuum.io/anaconda/faq.html
http://nbviewer.ipython.org/github/catherinedevlin/mpwfw_exercises/blob/master/setup.windows.ipynb
http://opentechschool.github.io/python-data-intro/core/notebook.html
Step 2: Tutorial Materials
The rest of this page assumes you have installed Anaconda and various python binaries are available in a terminal (Mac and Linux) or command prompt (Windows).
Attached below are the Ipython notebooks for the various tutorials.
On windows, the simplest option is to put these files in the "Ipython Notebooks" directory in the "My Documents" directory under "Documents" (i.e Documents --> My Documents --> IPython Notebooks).
You can open Ipython Notebook on various OSs as follows:
On Mac and LInux, open a terminal (and on Windows, open a command prompt) and change to the directory where your notebooks are. Then type:
ipython notebook
from the directory where you have all the following files (you need to have Anaconda bin directory in the path). Once the ipython server and the browser are up, you will see the files with 'ipynb' extension in the dashboard. Clicking on it will open it.
(On windows, there should be an ipython notebook launcher under Anaconda in the Start Menu. However, the better option is to open the notebook as described above.)
python-session1-basics-modified.ipynb
Simple File and Data Manipulation
total_petroleum_consumption_thousand_barrels_per_day.csv
Python and Numerics
Simple numerics and plotting
python-session2-numpy-matplotlib-modified.ipynb
Advanced Numerics
python-session3-numpy-projects.ipynb
Python and machine learning with scikit-learn
SVM-activity-identification-03302015.ipynb
PCA-image-compression-03302015.ipynb
Copyright © 2024 The President and Fellows of Harvard College * Accessibility * Support * Request Access * Terms of Use