
Today we will run a complete data science workflow together, from a data file on the course website to a finished chart. Weβre jumping into the whole workflow on the very first day, before we learn how the individual pieces work, so that you get an early sense of where we are going, and of the overall structure and rhythm of python and its data science libraries.
This morning has two parts. First we will meet python in Positron, which is where we will write our code for the rest of the course (and, likely, for much of your time in the MEDS program). The version of Positron we will be using runs in a browser on the Bren server, so there is nothing for you to install. Then we will cover just enough Python βgrammarβ to read the afternoonβs code: what a variable is, what a string is, how to use print statements, and how to write an f-string.
In the afternoon, across two sessions, we will analyze a single file of daily Arctic weather, recorded at Toolik Lake in Alaska between June 1988 and December 2018. By the end of the day, you will have imported that file, explored it, grouped it, aggregated it, drawn a chart from it, and exported the result. We do not clean the dataset, because the temperature column we analyze, Daily_AirTemp_Mean_C, has no missing values. We will spend Day 4 on cleaning and transforming data. Some of the afternoon will probably feel like copy-and-paste, and much of it may feel foreign (which is fine, and expected!), though you will write f-strings of your own, using what you learn in the morning session. Today is only an introduction, and none of it has to stick yet! By the end of the course, the commands and tools we use today should feel familiar, and todayβs session pages will still be here whenever you want to look up how we did something.
Class materials
| When | First session | Second session |
|---|---|---|
| day 1 / morning | βοΈ Positron & Jupyter Notebooks | π Python Essentials: Variables, Strings & f-strings |
| day 1 / afternoon | π¬ The Python Data Science Workflow, Part 1: Import to Aggregate | π¬ The Python Data Science Workflow, Part 2: Visualize, Export & Name the Workflow |
End-of-day practice
Before you leave today, run the same workflow again on your own, changing a few things just to see what happens. Nobody expects you to understand every line yet! If something breaks and you cannot work out why, come and find Cella or Kelly, who are both in the room for the whole practice. Today we are learning a valuable skill: reading working code, tinkering with it, and changing it on purpose to get a new result. Reading and tinkering with code you did not write is something you will do every day for the rest of the course.
Additional Resources
- The Data Science Workflow: the ten steps, and where you will learn each one
- Setting up Python: only if you want Python on your own laptop as well. Our course runs entirely on the Bren server, so you do not need to install anything.
- Positron cheatsheet
- First steps in Python
- Reading Python errors: what a traceback is telling you. We do not give errors a session of their own, so save this link for the first traceback that stops you.