The imbizo will involve a lot of Python coding, so please go through this tutorial before the course begins so we can hit the ground running when we get here.
This tutorial assumes some familiarity with programming but not necessarily with Python. If you are brand new to programming, follow the installation steps listed below, then check out Sections 3-5 of the official Python tutorial before starting this one.
To run this tutorial you'll need a Python 3 installation, along with the following scientific packages: numpy, scipy, pandas, matplotlib, and jupyter.
The easiest way to get going is to follow the Jupyter Notebook Quickstart Guide. This will have you install Anaconda (a scientific Python distribution with all the packages we'll use) and show you how to run your first Jupyter notebook.
If you have a slow connection or are short on hard drive space, you can alternatively install MiniConda for Python 3.7, and install the required packages individually using conda
, as described in the link.
Search around for your problem on Google/Stackoverflow, as many others will probably have encountered and solved the same situation. If you still can't find the answers you need, you can email one of the TAs. Installing Anaconda and Jupyter, however, should be fairly straightforward.
The tutorial is broken into three main instructional notebooks.
1_basic_python goes over the basics of using Python as a programming language.
2_scientific_python introduces common scientific operations and how to do them in Python. By the end of this notebook you should have the bare minimum you need to do a complete course project in Python.
3_tips_tricks_gotchas goes over several important gotchas (things to be aware of that may catch you off guard) and some helpful tips and tricks to speed up your Python and make it more fun.
There is also an exercises notebook to help you test your skills and knowledge.
Note that true Pythonistas may notice that not everything in this notebook is done in the most "Pythonic" way, but rather in a way to emphasize clarity and conceptual simplicty. But there are often many other and better ways of doing what's shown in these notebooks!
Click the green "Clone or Download" link in the upper right and save this tutorial to your computer.
Next, set the Jupyter startup folder to be the folder you downloaded the tutorial into, as per section 3.1.1/3.1.2 in the Jupyter Notebook Quickstart Guide. (Alternatively, if launching Jupyter from the command line, just make sure to cd
into the tutorial directory before running jupyter notebook
.)
Open the Jupyter notebook 0_start_here, put your cursor in the first cell and hit CTRL + ENTER. If it prints out a welcome message you've done everything right and are good to go.
Close and shutdown 0_start_here and open 1_basic_python to begin!
- Read over the whole tutorial in detail (notebooks 0-3), running the code cells as you encounter them and ensuring you understand exactly what's going on in each. Don't worry about memorizing syntax. The idea is to show you what Python can do in a scientific context and to give you a reference you can come back to.
- With the tutorial open as a reference, work through the exercises. Don't look at the solutions until you finish the exercise or if you really get stuck.
- If you feel confident in your ability to do the exercises, you're ready for the big time.