top of page

Finished code from workshops

This page includes descriptions of, and links to, examples of the finished codes created in D2I's day-to-day Python workshops.

Workshop 1: simple plots and reading data from links

The code from the first day-to-day workshop D2I ran gets CSVs directly from the link on the DfE website into pandas. This involves using the zipfile and IO Bytes modules. Some simple conditional slicing of the dataframe is done before a custom seaborn bar plot is made. Find the GitHub for this code here.

Workshop 2: merges, plotting dates, and linear regression

The code from the second workshop gets CSVs directly from the same directory as the Python file and uses a Jupyter notebook. The code then merges tables from those CSVs to create a data set, and plots them using matplotlib. Some formatting is done using datetime and mdates so that the plot can be done as dates, and also scipy.stats can be used to make a linear regression of the data on the same plot. Find the GitHub for this code here.

Workshop 3: Loops and functions - writing less code to do more work
forloopcode.png

Building on skills from previous workshops, this workshop introduces functions and for loops generally, and then shows how we can use them to re-use bits of code to generate a number of related visualisations and analyses for different factors whilst only writing the visualisation code once. The code is here.

Workshop 4: Writing functions from scratch

This workshop goes through the process of how one might go from a brief to writing the code for it in Python helping to explain how one would write a function in a way that's really useful. It also has an exercise for at the end to practice what you've learned. All the code is on JupyterLite too so you don't even need Python installed to read the workshop and practice yourself. The code is here.

headcount regression.png
Workshop 5: Further functions and lambda functions
roc curve.png

In this workshop, we build on workshop four, learning how to use functions in a slightly different way, and also how to use lambda functions, which may be most simply though of as really short quick functions that can either be given to a variable, or applied in place. Again, there's some exercises at the end to practice what you've learned, and a demonstration of how you might use the code you've made to do a visualisation. The code is on JupyterLite here, and GitHub here.

bottom of page