Module overview
Researchers routinely work with datasets originating from multiple sources, formats and software packages, often containing missing values, duplicated records, inconsistent coding schemes and other issues that require careful preprocessing before meaningful statistical analyses can be performed. Learning how to create and apply computational workflows to transform heterogeneous raw data into analysis-ready datasets that support reliable scientific inference is therefore an essential research skill. At the same time, recent advances in artificial intelligence (AI) are transforming the way scientists write code, automate repetitive tasks and document their analyses. Developing the skills to combine Python programming with the effective and critical use of AI-assisted coding tools has become an increasingly important component of modern research training.
This module provides a practical introduction to advanced data preparation using Python and AI-assisted programming. Through four hands-on sessions organised around progressively more challenging research “Missions”, participants will learn how to read, inspect, clean, merge and transform complex datasets; automate preprocessing pipelines; visualise and summarise data; and use conversational AI assistants responsibly to accelerate coding, improve documentation and support reproducible research practices. Emphasis is placed on developing reusable workflows that participants can readily adapt to their own research projects, while maintaining a clear understanding of the underlying Python code and ensuring scientific rigour. AI is treated as an assistant, not as a replacement for programming knowledge.
Prerequisites
- Basic experience writing and running Python scripts, with familiarity with Python syntax.
- Familiarity with core Python concepts, including basic data types, common data structures (lists, tuples, and sets), operators and control flow statements.
Participants without prior Python experience are strongly encouraged to complete the Introduction to Python module before attending this course.
Participants should bring their own laptop with a working Python installation (e.g. Visual Studio Code and/or JupyterLab) and the required libraries (NumPy, Pandas and related dependencies) installed before the start of the course. Installation instructions will be provided in advance. Participants should also download the course materials beforehand to ensure access to the datasets, code examples and supporting documentation used during the practical sessions. Participants are encouraged to bring one of their own datasets to the final session, where they will have the opportunity to apply the techniques learned throughout the module to their own research.
Topics covered
Session 1: Reading, Inspecting and Cleaning Research Data. Introduction to key data structures for scientific computing, including Python dictionaries, NumPy arrays, and Pandas Series and DataFrames. Importing data from multiple file formats using Pandas and JSON. Inspecting datasets using essential summary and diagnostic functions. Applying core data cleaning techniques, including detecting and removing duplicates, handling missing values (e.g. deletion or imputation), and identifying outliers using statistical approaches such as the interquartile range (IQR) and z-scores.
Mission 1. Import a heterogeneous, “messy” dataset from multiple sources and develop a rule-based data cleaning workflow that preserves data integrity.
AI Skill. Use AI to generate structured datasets from web resources or uploaded documents.
Session 2: Merging, Selecting and Re-encoding Data. Combining datasets using merge and join operations. Reshaping and summarising data with groupby() to support statistical analyses and data visualisation. Exploring and visualising datasets with Matplotlib and Seaborn to assess data quality and support downstream analyses. Creating and recoding variables using vectorised operations and the apply() function. Revisiting user-defined functions to support reusable data transformations. Cleaning text data with Regular Expressions (Regex). Understanding label-based and integer-based indexing, advanced filtering and Boolean indexing for efficient data selection.
Mission 2. Combine multiple cleaned datasets into a unified master dataset, explore and visualise the data, and generate new variables to prepare the dataset for downstream analyses.
AI Skill. Use AI to design and refine complex Regular Expressions (Regex) for text extraction, cleaning and data transformation.
Session 3: Automating Data Transformation with Loops and Batch Processing. Developing reusable workflows to automate repetitive data preparation tasks. Processing multiple datasets efficiently using for loops and the os or pathlib libraries to iterate over files and directories. Extending knowledge of control flow statements and modular programming to build scalable data processing pipelines. Generating publication-quality figures and summary outputs automatically from multiple datasets.
Mission 3. Develop a reusable Python script that processes multiple datasets in batch, performs automated data cleaning and transformation, and generates publication-quality figures together with a summary report.
AI Skill. Use AI to generate reusable plotting functions, modular data-processing code, and helper functions to improve code organisation and reusability.
Session 4: AI-Assisted Reproducible Research. Learning to critically evaluate AI-generated code by recognising both its strengths and limitations and using it to accelerate rather than replace scientific programming. Applying prompt engineering techniques to interact effectively with conversational AI assistants based on large language models (LLMs). Using AI to refactor code, generate docstrings and README files, and improve code readability, modularity and documentation. Translating methodology sections from scientific papers into executable computational workflows to support reproducible implementations. Introducing essential reproducibility practices, including version control with Git, dependency management using environment.yml or requirements.txt, and basic unit testing with pytest. The session concludes with participants applying these techniques to data handling problems provided by the instructor or to their own research datasets.
Mission 4. Apply the complete workflow to a provided example dataset or participants’ own research data. Critically evaluate, improve, document and organise the code with AI assistance while ensuring reproducibility.
AI Skill. Use AI to review, refactor, document and validate scientific code while maintaining a critical understanding of the underlying implementation.
Objectives
Learning objectives:
Aim: Develop practical skills for transforming heterogeneous research data into analysis-ready datasets using Python and AI-assisted programming techniques. By the end of the module, participants will have the practical skills to develop reusable Python workflows for their own research projects and to integrate AI responsibly into their computational practice.
Specific objectives:
- Read and import data from different sources and file formats.
- Inspect, summarise and visualise datasets.
- Transform, reshape and recode data into analysis-ready formats.
- Select, index and filter data efficiently.
- Identify and handle duplicates, missing values and outliers.
- Combine datasets and save clean datasets for downstream analyses.
- Process multiple datasets efficiently using loops and other automation strategies.
- Automate repetitive preprocessing tasks using reusable Python scripts.
- Critically evaluate and integrate AI-generated code into scientific workflows.
- Apply good practices for reproducible research, including code documentation, version control and project organisation.
Format
The module consists of four in-person sessions of two hours each. Each session combines short instructor-led presentations with hands-on programming exercises centred around progressively more challenging research “Missions”. Emphasis is placed on active learning, with each new concept immediately reinforced through guided practical activities. Throughout these exercises, participants will develop and execute Python code to solve realistic data preparation and automation problems while learning how to integrate AI tools effectively and critically into their workflow. Datasets and supporting materials will be provided as part of the course resources. Participants are encouraged to bring one of their own datasets to the final session, where they will have the opportunity to apply the techniques learned throughout the module to their own research questions.
System requirements
Participants should have Internet access to interact with an AI coding assistant (e.g. ChatGPT or similar) during the AI-assisted programming exercises.
How to Book
Cambridge University postgraduate students and staff can book directly onto this module using the booking link provided. Please check that you are eligible before you make a booking. As soon as you book, you will receive an automated email confirming your place.
External participants and postgraduate students from Anglia Ruskin University should complete the Booking Request Form which you can find on the How to Book page.
Please note, some modules have multiple iterations in the Michaelmas and Lent Term.
Sessions
| Date | Time | Teaching Format | Instructor |
|---|---|---|---|
| Wed 24 Feb 2027 | 10:00-12:00 | In person venue | Maité Crespo García |
| Wed 03 Mar 2027 | 10:00-12:00 | In person venue | Maité Crespo García |
| Wed 10 Mar 2027 | 10:00-12:00 | In person venue | Maité Crespo García |
| Wed 17 Mar 2027 | 10:00-12:00 | In person venue | Maité Crespo García |