Summary and Setup

This lesson is an introduction to programming in Python for library and information workers with little or no previous programming experience (see the Learner Profiles for examples of the kinds of people who might benefit from this lesson). It uses examples that are relevant to a range of library use cases, and is designed as a prerequisite for other Python lessons that will be developed in the future (e.g., web scraping, APIs). The lesson uses the JupyterLab computing environment and Python 3.

Prerequisite

Prerequisites

  1. Learners need to understand what files and directories are and what a working directory is.

  2. Learners must install Python and JupyterLab, and download the dataset that will be used in the lesson, before the workshop begins.

Please see setup instructions below for details.

Learning Objectives


After attending this training, participants will be able to:

  • Learn core Python syntax, variables, data types, and functions while using the JupyterLab interface.
  • Control program execution using lists, loops, conditional logic, and custom functions to automate data tasks.
  • Load, clean, aggregate, and reshape tabular datasets using the Pandas library to create analysis-ready data.
  • Generate insightful charts from tidy datasets using Pandas and Plotly.

Installing Python Using Miniforge


Python is a popular language for scientific computing, and great for general-purpose programming as well. For this workshop we use Python version 3.x. Installing all of its scientific packages individually can be a bit difficult, so we provide an environment file to help you take care of them all together. We will use the Miniforge distribution of Python.

Please refer to the Python section of the workshop website for installation instructions.

JupyterLab


We will teach Python using JupyterLab, a part of a family of Jupyter tools that includes Jupyter Notebook and JupyterLab, both of which provide interactive web environments where you can write and run Python code. If you followed the instructions linked above, JupyterLab is installed on your system. Alternatively, you can install JupyterLab on its own using conda, pip, or other popular package managers.

Download the data


  1. Download this zip file and save it to your Desktop.
  2. Unzip the data.zip file, which should create a new folder called data.
  3. Create a new folder on your Desktop called lc-python and put the data folder in this folder.

This lesson uses circulation data in multiple CSV files from the Chicago Public Library system. The data was compiled from records shared by the Chicago Public Library via data.cityofchicago.org, and available in the the data.gov catalog. The original data is in the public domain with an open license which is defined as “any legally binding instrument that grants permission to access, re-use, and redistribute a work with few or no restrictions.” The CSV files used in this lesson were modified for ease of use and teaching purposes.