← Back to courses

Course

Pandas - Data Analysis with Python

103 lessons across 10 modules

Beginner to intermediate, assuming Core Python and basic NumPy. Reading data from files, databases and APIs, selecting and filtering, cleaning, transforming, grouping, joining, strings and dates, reshaping, and working at scale, then preparing data for machine learning - ending in four projects. The road is laid out in full; lessons are being written one at a time.

Course10 modules103 lessonsEach heading below is a module (one topic). Each card under it is a lesson. Start with Module 1.
Solid: ready (0)Dashed: coming soon (103)
Module 1 of 107 lessonsComing soon

Pandas Fundamentals

Series, DataFrames, and a first look at real data

Prerequisite: the NumPy course →

What is Pandas?

1

Labelled, tabular data in Python - and where it sits beside NumPy.

A spreadsheet task done in three lines of Pandas

Lesson 1planned

Installing and Importing Pandas

2

Installing with pip, importing as pd, and checking the version.

import pandas as pd, the convention every example follows

Lesson 2planned

Pandas Data Structures

3

Series, DataFrame, and the Index that labels both.

One column pulled out of a DataFrame as a Series

Lesson 3planned

Creating a Series

4

A labelled one-dimensional array, with a default or custom index.

Scores indexed by student name instead of 0, 1, 2

Lesson 4planned

Creating a DataFrame

5

From dictionaries, lists of rows, and NumPy arrays.

Names, ages, and salaries as a three-column table

Lesson 5planned

DataFrame Attributes

6

shape, size, columns, index, dtypes, and ndim.

A salary column stored as text, spotted from dtypes

Lesson 6planned

Inspecting Data

7

head, tail, sample, info, and describe - a first look at any dataset.

The five commands to run on every new file

Lesson 7planned
Module 2 of 109 lessonsComing soon

Reading and Writing Data

Getting data in from files, databases, and APIs - and back out

Reading CSV Files

8

read_csv, and the defaults it applies without asking.

A leading-zero postcode turned into a number

Lesson 8planned

Writing CSV Files

9

to_csv, and index=False to avoid an extra column.

An unnamed index column appearing on every re-read

Lesson 9planned

Reading Excel Files

10

read_excel, sheets, and the engine it needs installed.

Reading one named sheet from a workbook

Lesson 10planned

Writing Excel Files

11

to_excel, and writing several sheets into one workbook.

A report with one sheet per region

Lesson 11planned

Reading JSON

12

read_json, and json_normalize for nested records.

Nested API records flattened into columns

Lesson 12planned

Reading SQL Data

13

read_sql with a connection, and filtering in SQL rather than Pandas.

A query that returns a thousand rows instead of a million

Lesson 13planned

Reading Data from APIs

14

Fetching JSON over HTTP and turning it into a DataFrame.

A paginated API collected into one table

Lesson 14planned

Handling File Paths and Encodings

15

Paths that work everywhere, and encoding errors on read.

A UnicodeDecodeError fixed by naming the encoding

Lesson 15planned

Important read_*() Options

16

usecols, dtype, skiprows, nrows, na_values, and parse_dates.

A large file read in a fraction of the memory with usecols and dtype

Lesson 16planned
Module 3 of 109 lessonsComing soon

Selecting and Filtering Data

Getting exactly the rows and columns you need

Selecting Columns

17

One column as a Series, a list of columns as a DataFrame.

df["name"] against df[["name"]], and why the brackets matter

Lesson 17planned

Selecting Rows

18

Row slicing with plain brackets, and why it confuses people.

df[0:3] selecting rows while df["x"] selects a column

Lesson 18planned

loc[]

19

Selection by label - and loc slices include the end.

loc[0:2] returning three rows, not two

Lesson 19planned

iloc[]

20

Selection by position, with the end excluded like Python.

The first three rows and first two columns by position

Lesson 20planned

Boolean Filtering

21

Keeping the rows where a condition is true.

Every employee earning over 50,000

Lesson 21planned

Multiple Conditions

22

& and | with brackets - never and or or.

A ValueError from and, fixed with & and brackets

Lesson 22planned

isin()

23

Matching any value from a list.

Rows from three chosen departments

Lesson 23planned

between()

24

An inclusive range filter.

Ages from 25 to 35

Lesson 24planned

query()

25

Filters written as a readable string.

A three-condition filter that reads like a sentence

Lesson 25planned
Module 4 of 1011 lessonsComing soon

Data Cleaning

The work that takes most of the time in any real analysis

Understanding Missing Data

26

NaN, None, NA, and NaT - and why missing is not zero.

An average that changes completely once missing values are handled

Lesson 26planned

Detecting Missing Values

27

isna and isnull, and counting the gaps per column.

A column that is forty per cent missing

Lesson 27planned

Removing Missing Values

28

dropna, with how, subset, and thresh.

Dropping only the rows missing a required field

Lesson 28planned

Filling Missing Values

29

fillna with a constant, a statistic, or per-column values.

Missing ages filled with the median, not the mean

Lesson 29planned

Forward Fill and Backward Fill

30

Carrying the last known value forward or the next one back.

Gaps in a sensor reading filled from the reading before

Lesson 30planned

Handling Duplicate Data

31

Finding and removing duplicates, and choosing which to keep.

Keeping the latest record for each customer

Lesson 31planned

Handling Incorrect Data

32

Values that are present but impossible.

A negative age and a date in the future, corrected

Lesson 32planned

Data Type Conversion

33

astype, to_numeric with errors, and nullable integer types.

astype(int) failing on a NaN, fixed with Int64

Lesson 33planned

Cleaning Column Names

34

Lowercase, stripped, and consistent names you can type.

Column names with trailing spaces breaking a lookup

Lesson 34planned

Handling Outliers

35

Detecting with IQR or z-scores, then deciding what to do.

An outlier that was a real value, not an error

Lesson 35planned

Data Cleaning Workflow

36

Missing values, duplicates, invalid values, types, and outliers, in order.

A raw file turned into a clean dataset, step by step

Lesson 36planned
Module 5 of 1010 lessonsComing soon

Sorting, Ranking and Data Transformation

Ordering data and deriving new columns from it

Sorting Data

37

sort_values, ascending or descending, and where NaN ends up.

The highest salaries first

Lesson 37planned

Sorting by Multiple Columns

38

Several sort keys, each with its own direction.

By department ascending, then salary descending

Lesson 38planned

sort_index()

39

Restoring or imposing order by the index.

A filtered frame put back into its original order

Lesson 39planned

Ranking Data

40

rank, and the tie methods that change the answer.

Two tied salaries ranked average, min, and dense

Lesson 40planned

Creating New Columns

41

Derived columns - and the chained-assignment warning.

A SettingWithCopyWarning from a filtered frame, and the fix

Lesson 41planned

Applying Functions

42

apply on a Series and on rows - flexible, but slow.

An apply that a vectorised expression replaces

Lesson 42planned

map()

43

Mapping values through a dictionary or a function.

Department codes turned into department names

Lesson 43planned

replace()

44

Swapping specific values, including with patterns.

Every "N/A" and "-" replaced with a real missing value

Lesson 44planned

assign()

45

Adding columns inside a method chain.

A clean, readable chain of transformations

Lesson 45planned

Conditional Transformation

46

Values chosen by condition - np.where and np.select over apply.

High, medium, and low salary bands in one vectorised call

Lesson 46planned
Module 6 of 1010 lessonsComing soon

Grouping and Aggregation

Split, apply, combine - the core of analysis

Understanding groupby()

47

Split into groups, apply a function, combine the results.

Employees split by department, drawn out

Lesson 47planned

Aggregation

48

Reducing each group to a single value.

Average salary per department

Lesson 48planned

Multiple Aggregations

49

Several statistics per group with agg.

Mean, min, and max salary in one table

Lesson 49planned

count(), sum(), mean()

50

The everyday aggregates, and count against size with NaN.

count and size disagreeing on a column with gaps

Lesson 50planned

min() and max()

51

Extremes per group, and idxmin and idxmax to find the row.

The highest-paid person in each department, not just the salary

Lesson 51planned

Grouping by Multiple Columns

52

Groups for every combination, and the MultiIndex they return.

Revenue per region per product

Lesson 52planned

Named Aggregations

53

Choosing the output column names as you aggregate.

total_revenue and avg_order instead of generated names

Lesson 53planned

value_counts()

54

How often each value occurs, as counts or proportions.

The share of orders from each region

Lesson 54planned

pivot_table()

55

A quick summary table - grouping laid out as rows and columns.

Revenue with regions down the side and months across the top

Lesson 55planned

Practical Grouping Problems

56

Real questions answered with groupby.

Total revenue, average revenue, and quantity for every region

Lesson 56planned
Module 7 of 1011 lessonsComing soon

Combining DataFrames

Stacking tables and joining related ones

Joins in the SQL course →

Why DataFrames Need to Be Combined

57

Real data arrives in several tables linked by keys.

Customers in one file, orders in another

Lesson 57planned

concat()

58

Stacking frames with the same columns on top of each other.

Twelve monthly files combined into one year

Lesson 58planned

Horizontal Concatenation

59

Placing frames side by side, aligned on the index.

Misaligned indexes producing a wall of NaN

Lesson 59planned

merge()

60

SQL-style joins on key columns.

Customers and orders joined on customer_id

Lesson 60planned

Inner Join

61

Only the keys found in both frames.

Customers who have placed at least one order

Lesson 61planned

Left Join

62

Every row from the left, matched where possible.

Every customer, with NaN where there are no orders

Lesson 62planned

Right Join

63

Every row from the right - usually rewritten as a left join.

The same result as a right and as a left join

Lesson 63planned

Outer Join

64

Every key from both sides, and the indicator column.

Records that exist in only one of two systems

Lesson 64planned

Merge on Multiple Columns

65

Composite keys, and validate to catch duplicate keys.

A merge that silently multiplied rows, caught by validate

Lesson 65planned

join()

66

Joining on the index rather than a column.

Two frames indexed by date joined in one call

Lesson 66planned

combine_first()

67

Filling the gaps in one frame from another.

Missing contact details patched from a second source

Lesson 67planned
Module 8 of 1010 lessonsComing soon

Working with Strings, Dates and Time

Text columns, datetimes, and time series

String Operations

68

The .str accessor for vectorised text operations.

Every name trimmed and lowercased in one line

Lesson 68planned

Searching Strings

69

contains, startswith, and case and missing-value handling.

A contains that crashed on NaN until na=False was set

Lesson 69planned

Splitting Strings

70

Splitting text into columns with expand.

A full name split into first and last name columns

Lesson 70planned

Replacing Strings

71

Replacing text, with and without regular expressions.

Currency symbols stripped so a price column can be numeric

Lesson 71planned

Converting Strings to Dates

72

to_datetime, explicit formats, and day-first ambiguity.

03/04/2024 read as March when it meant April

Lesson 72planned

Extracting Date Components

73

Year, month, day, weekday, and more through .dt.

Orders grouped by day of the week

Lesson 73planned

Date Filtering

74

Filtering by date range, and partial date strings.

Every order from the first quarter

Lesson 74planned

Date Differences

75

Subtracting dates to get durations.

Days between order and delivery

Lesson 75planned

Resampling Time-Series Data

76

Changing frequency - daily into weekly or monthly.

Daily sales totalled into monthly sales

Lesson 76planned

Time-Series Basics

77

A datetime index, and shifting values in time.

Each day compared with the same day last week

Lesson 77planned
Module 9 of 1013 lessonsComing soon

Advanced Pandas

Reshaping, window functions, and working at scale

MultiIndex

78

Creating an index with more than one level.

Rows labelled by both region and year

Lesson 78planned

Hierarchical Indexing

79

Selecting from a MultiIndex - tuples, xs, and slices.

Every year for one region, then one year across all regions

Lesson 79planned

pivot()

80

Reshaping long data to wide - it fails on duplicate entries.

A ValueError from pivot on a repeated pair

Lesson 80planned

pivot_table()

81

The reshaping view - aggregating duplicates, margins, and fill values.

The pivot that failed, fixed with pivot_table and a total row

Lesson 81planned

melt()

82

Reshaping wide data to long.

A column per month turned into one row per month

Lesson 82planned

stack() and unstack()

83

Moving index levels between rows and columns.

A grouped result unstacked into a readable grid

Lesson 83planned

Window Functions

84

rolling, expanding, and ewm, and what each window covers.

A seven-day, a cumulative, and a weighted average side by side

Lesson 84planned

Rolling Average

85

Smoothing noisy data, with min_periods and centring.

A seven-day average of daily sales

Lesson 85planned

Efficient Pandas Operations

86

What makes Pandas code fast or slow.

An analysis rewritten to run twenty times faster

Lesson 86planned

Vectorization vs apply()

87

Whole-column operations against a Python function per row.

An apply timed against the vectorised equivalent

Lesson 87planned

Memory Optimization

88

Smaller numeric types and the category dtype.

A DataFrame cut to a quarter of its memory

Lesson 88planned

Large Dataset Processing

89

When data no longer fits comfortably in memory, and the options.

Reading only the columns and rows you need

Lesson 89planned

Chunk Processing

90

Reading a file in pieces and combining the results.

A file larger than memory aggregated chunk by chunk

Lesson 90planned
Module 10 of 1013 lessonsComing soon

Pandas for Data Science and Projects

Exploring data, preparing it for models, and four projects

Exploratory Data Analysis

91

A structured first pass to learn what a dataset contains.

An EDA checklist run on an unfamiliar dataset

Lesson 91planned

Descriptive Statistics

92

Using summary statistics to answer real questions.

Whether the average salary misleads, answered with the median

Lesson 92planned

Correlation

93

How columns move together - and that correlation is not causation.

A strong correlation with an obvious hidden cause

Lesson 93planned

Detecting Data Patterns

94

Trends, seasonality, and segments in the data.

A weekly pattern hidden inside daily sales

Lesson 94planned

Pandas and NumPy

95

Moving between DataFrames and arrays, and when to drop down.

to_numpy for a calculation Pandas makes awkward

Lesson 95planned

Pandas and Matplotlib

96

Plotting straight from a DataFrame.

A monthly revenue chart from one grouped frame

Lesson 96planned

Pandas and Scikit-learn

97

DataFrames as model input, and keeping column names through a pipeline.

Features from a DataFrame passed into a model

Lesson 97planned

Preparing Data for Machine Learning

98

Cleaning, encoding, and selecting features for a model.

Categorical columns one-hot encoded with get_dummies

Lesson 98planned

End-to-End Data Analysis Workflow

99

Read, inspect, clean, transform, analyse, and report.

A question taken all the way from raw file to answer

Lesson 99planned

Project 1 - Student Performance Analysis

100

Cleaning, filtering, grouping, ranking, and performance analysis.

The subjects and students that need attention, identified

Lesson 100planned

Project 2 - E-Commerce Sales Analysis

101

Revenue by region and product, monthly sales, and order value.

Top products and customers, and the average order value

Lesson 101planned

Project 3 - Employee Data Analysis

102

Salary by department, experience, distribution, and hiring trends.

Joining trends over time and salary spread per department

Lesson 102planned

Final Project - Real-World Data Analysis Pipeline

103

A public dataset taken from source to charts and a final report.

A clean dataset, a notebook, charts, and business insights

Lesson 103planned