Python Crash Course

Oct 26-27, 2017

9:00 am - 5:00 pm

Instructors: Daniel Chen

Helpers:

Resources

Download the repository (that includes the data) here: https://github.com/chendaniely/2017-10-26-python_crash_course/archive/gh-pages.zip additional datasets, if you already downloaded the zipfile: Other paper references:

Data Camp Courses

Schedule

Day 1

09:00 Different ways you can interface with Python
09:30 Pandas DataFrame basics
10:30 Break
10:40 Pandas data structures
11:40 Quick overview of plotting methods
12:00 Lunch
13:30 Assembling data
14:00 Missing Values
14:30 Break
14:45 Data Reshaping
15:45 Data Types
16:15 Functions
17:00 Finish Day 1

Day 2

09:00 Strings and Text Data in Python
10:00 Functions and Apply
10:30 Break
10:45 Applying over rows and columns
11:15 Grouped operations
12:00 Lunch
13:00 Dates and Times
14:00 Linear Models
14:30 Break
14:45 Fitting Models
15:45 Thinking about performance
16:00 Good Practices and Wrap-up
17:00 Finish Day 2

Syllabus

Setup

To participate in a workshop, you will need access to the software described below. In addition, you will need an up-to-date web browser.

We maintain a list of common issues that occur during installation as a reference for instructors that may be useful on the Configuration Problems and Solutions wiki page.

Python

Python is a popular language for research computing, and great for general-purpose programming as well. Installing all of its research packages individually can be a bit difficult, so we recommend Anaconda, an all-in-one installer.

Regardless of how you choose to install it, please make sure you install Python version 3.x (e.g., 3.4 is fine).

We will teach Python using the IPython notebook, a programming environment that runs in a web browser. For this to work you will need a reasonably up-to-date browser. The current versions of the Chrome, Safari and Firefox browsers are all supported (some older browsers, including Internet Explorer version 9 and below, are not).

Windows

Video Tutorial
  1. Open http://continuum.io/downloads with your web browser.
  2. Download the Python 3 installer for Windows.
  3. Install Python 3 using all of the defaults for installation except make sure to check Make Anaconda the default Python.

Mac OS X

Video Tutorial
  1. Open http://continuum.io/downloads with your web browser.
  2. Download the Python 3 installer for OS X.
  3. Install Python 3 using all of the defaults for installation.

Linux

  1. Open http://continuum.io/downloads with your web browser.
  2. Download the Python 3 installer for Linux.
    (Installation requires using the shell. If you aren't comfortable doing the installation yourself stop here and request help at the workshop.)
  3. Open a terminal window.
  4. Type
    bash Anaconda3-
    and then press tab. The name of the file you just downloaded should appear. If it does not, navigate to the folder where you downloaded the file, for example with:
    cd Downloads
    Then, try again.
  5. Press enter. You will follow the text-only prompts. To move through the text, press the space key. Type yes and press enter to approve the license. Press enter to approve the default location for the files. Type yes and press enter to prepend Anaconda to your PATH (this makes the Anaconda distribution the default Python).
  6. Close the terminal window.

Testing If Anaconda was installed

  1. Open up the Anaconda Command Prompt
  2. Type "ipython" into the prompt
  3. You should see Python open up with Python 3.6.x and using the Anaconda distribution
  4. Type "quit()" to exit
  5. Type "jupyer notebook" to launch the notebook (this may take a while if it is the first time you are launching it)
  6. Close the anaconda prompt when you're done

Installing Packages

To install the packages needed for the class you can follow the instructions below:
  1. Open your Anaconda Command prompt (Windows)
  2. Run the following lines of code (note that ctrl+v may not paste in windows, you can paste by pressing shift + insert, or by clicking the icon to the top right of the Anaconda Command promt > edit > paste)
  3. conda install xlwt openpyxl feather-format seaborn statsmodels scikit-learn regex wget odo numba
    pip install lifelines pandas-datareader