Summary and Schedule
This lesson is an introduction to programming in Python for library and information workers with little or no previous programming experience. 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.
Setup Instructions | Download files required for the lesson | |
Duration: 00h 00m | 1. Getting Started |
How do I use JupyterLab? How can I run Python code in JupyterLab? |
Duration: 00h 20m | 2. Variables and Types |
How can I store data in Python? What are some types of data that I can work with in Python? |
Duration: 00h 45m | 3. Lists | How can I store multiple items in a Python variable? |
Duration: 01h 20m | 4. Built-in Functions and Help |
How can I use built-in functions? How can I find out what they do? What kind of errors can occur in programs? |
Duration: 01h 45m | 5. Libraries & Pandas |
How can I extend the capabilities of Python? How can I use Python code that other people have written? How can I read tabular data? |
Duration: 02h 15m | 6. For Loops | How can I execute Python code iteratively across a collection of values? |
Duration: 02h 55m | 7. Looping Over Data Sets | How can I process many data sets with a single command? |
Duration: 03h 15m | 8. Using Pandas |
How can I work with subsets of data in a pandas DataFrame? How can I run summary statistics and sort columns of a DataFrame? How can I save DataFrames to other file formats? |
Duration: 03h 45m | 9. Conditionals | How can programs do different things for different data? |
Duration: 04h 10m | 10. Writing Functions |
How can I create my own functions? How do variables inside and outside of functions work? How can I make my functions easier to understand? |
Duration: 04h 35m | 11. Tidy Data with Pandas |
What are the benefits of transforming data into a tidy format for
analysis? How does the melt() function in pandas facilitate data tidying? What are some practical challenges when working with real-world datasets in Python, and how can they be addressed? :::::::::::::::::::::::::::::::::::::::::::::::::: |
Duration: 06h 15m | 12. Data Visualisation | How can I use Python tools like Pandas and Plotly to visualize library circulation data? |
Duration: 06h 45m | 13. Wrap-Up |
What have we learned? What else is out there and where do I find it? How can I make my programs more readable? |
Duration: 06h 55m | Finish |
The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.
Installing Python Using Anaconda
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 3.6 or above. The latest 3.x version recommended on Python.org is fine.
We will teach Python using JupyterLab, a programming environment that runs in a web browser (JupyterLab will be installed by Anaconda). 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
Open anaconda.com/download with your web browser.
Download the Anaconda for Windows installer with Python 3. (If you are not sure which version to choose, you probably want the 64-bit Graphical Installer Anaconda3-…-Windows-x86_64.exe)
Install Python 3 by running the Anaconda Installer, using all of the defaults for installation except make sure to check Add Anaconda to my PATH environment variable.
macOS - Video tutorial
- Open anaconda.com/download with your web browser.
- Download the Anaconda Installer with Python 3 for macOS (you can either use the Graphical or the Command Line Installer).
- Install Python 3 by running the Anaconda Installer using all of the defaults for installation.
Linux
Note that the following installation steps require you to work from the shell. If you aren’t comfortable doing the installation yourself stop here and request help from the workshop organizers.
Open anaconda.com/download with your web browser.
Download the Anaconda Installer with Python 3 for Linux.
Open a terminal window and navigate to the directory where the executable is downloaded (e.g.,
cd ~/Downloads
).Type
bash Anaconda3
and press Tab to auto-complete the full file name. The name of file you just downloaded should appear.Press Enter (or Return depending on your keyboard). 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 (or Return) to approve the default location for the files. Typeyes
and press Enter (or Return) to prepend Anaconda to your PATH (this makes the Anaconda distribution the default Python).Close the terminal window.
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 installed Anaconda, JupyterLab is installed on your system. If you did not install Anaconda, you can install JupyterLab on its own using conda, pip, or other popular package managers.
Download the data
- Download this zip file and save it to your Desktop.
- Unzip the
data.zip
file, which should create a new folder calleddata
. - Create a new folder on your Desktop called
lc-python
and put thedata
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 in the data.gov catalog. Please do not download the circulation data from data.gov since the dataset you downloaded following the steps above has been altered for our purposes.