Introduction to Python for Data Science

KAUST Visualization Core Lab

2 March 2021

1:00 pm - 5:00 pm

Instructors: Dr. David R. Pugh

Helpers: Glendon Holst

General Information

The KAUST Visualization Lab is hosting an Introduction to Python for Data Science workshop. Visualization lab staff will provide an introduction to Python for data science designed for learners with little or no previous programming experience. Topics covered will include

This hands-on lesson is part of the Introduction to Data Science Workshop Series being offered by KVL as part of our on-going efforts to build capacity in core data science skills both at KAUST and within the Kingdom of Saudi Arabia (KSA).

The workshop curriculum largely follows the curriculum developed by Software Carpentry, a volunteer project dedicated to helping researchers get their work done in less time and with less pain by teaching them basic research computing skills.

This is a live-coding based workshop and learners are expected to work along with the instructor using freely available cloud resources provided by the Binder project.

For more information on what Software Carpentry teaches and why, please see their paper "Best Practices for Scientific Computing".

Who: The course is aimed at graduate students (MSc and PhD), post-docs, scientists, faculty, and industry researchers and practioners at KAUST and within the Kingdom of Saudi Arabia (KSA).

When: 2 March 2021. Add to your Google Calendar.

Registration: KAUST Affiliated, Non-KAUST Affiliated

Contact: Please email help@vis.kaust.edu.sa for more information.


Code of Conduct

Everyone who participates in Carpentries activities is required to conform to the Code of Conduct.This document also outlines how to report an incident if needed.


Collaborative Notes

We will use this collaborative document for chatting, taking notes, and sharing URLs and bits of code.


Surveys

Please be sure to complete these surveys before and after the workshop.

Pre-workshop Survey

Post-workshop Survey


Schedule

Before Pre-workshop survey
09:00 Introduction to Python
10:30 Morning break
10:45 Introduction to Pandas
12:00 Lunch break
13:00 Building Programs with Python
14:30 Afternoon break
14:45 Python Programming "Best Practices"
16:30 Wrap-up
17:00 END
After Post-workshop survey

Syllabus

Programming in Python

  • Running and Quiting
  • Variables and Assignment
  • Data Types and Type Conversion
  • Built-in Functions and Help
  • Libraries
  • Reading Tabular Data into DataFrames
  • Pandas DataFrames
  • Lists
  • For Loops
  • Looping Over Data Sets
  • Writing Functions
  • Variable Scope
  • Conditionals
  • Programming Style
  • Reference...

Setup

To participate in a Software Carpentry 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.

Text Editor

When you're writing code, it's nice to have a text editor that is optimized for writing code, with features like automatic color-coding of key words. The default text editor on macOS and Linux is usually set to Vim, which is not famous for being intuitive. If you accidentally find yourself stuck in it, hit the Esc key, followed by :+Q+! (colon, lower-case 'q', exclamation mark), then hitting Return to return to the shell.

Visual Studio Code is a source-code editor developed by Microsoft for Windows, Linux and macOS. It includes support for debugging, embedded Git control and GitHub, syntax highlighting, intelligent code completion, snippets, and code refactoring. It is highly customizable, allowing users to change the theme, keyboard shortcuts, preferences, and install extensions that add additional functionality. The source code is free and open source and released under the permissive MIT License.

Python

Python is a popular language for research computing, and great for general-purpose programming as well. While there are many different ways to install Python, we recommend installing the 64-bit Python 3 version of Miniconda.

We will teach Python using the JupyterLab, 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.

  1. Open https://docs.conda.io/en/latest/miniconda.html with your web browser.
  2. Download the 64-bit Python 3 installer for Windows.
  3. Install Python 3 using all of the defaults for installation except make sure to check Add Miniconda to my PATH environment variable.
  1. Open https://docs.conda.io/en/latest/miniconda.html with your web browser.
  2. Download the 64-bit Python 3 installer for Linux. The 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 Miniconda3-
    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 Return. You will follow the text-only prompts. To move through the text, press Spacebar. 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 Miniconda to your PATH (this makes the Miniconda distribution the default Python).
  6. Close the terminal window.