← All Kits · Python Kit

Python Drills for Analysts: Twenty Minutes a Day on One Small Table

Michael Nocito · Updated August 2026 · Every number on this page was worked before it was published

Most people learn pandas by reading a notebook that already works. It feels productive and it produces recognition rather than recall: you can follow every line and you cannot write any of them from a blank file.

What you do: keep one small table, and type a short set of drills against it every day. Twenty minutes, six sets, and predict every answer before you press run.

The short version. Practice is only practice if you could have got it wrong.

The table

Small enough to retype from memory, varied enough to be interesting. Type it, do not copy it: retyping is the first drill.

import pandas as pd

df = pd.DataFrame({
    'order_id': [101, 102, 103, 104, 105, 106, 107, 108],
    'region':   ['North','North','South','South','East','West','West','East'],
    'month':    ['Jan','Feb','Jan','Feb','Jan','Jan','Feb','Feb'],
    'amount':   [120, 80, 200, 50, 300, 90, 60, 150],
    'status':   ['shipped','shipped','cancelled','shipped',
                 'shipped','pending','shipped','cancelled'],
})

Eight rows, 1,050 total. Four regions, two months, three statuses. Every answer below is small enough to work out in your head first, which is the point.

The six sets

Set 1: look at it

df.shape            # (8, 5)
df.dtypes
df.head(3)
df['region'].value_counts()
df.describe()

Do this every day even when you know the answer. On real data these five lines are the first five things you should run, and the habit is worth more than the syntax.

Set 2: filter

df[df['amount'] > 100]
df[(df['region'] == 'North') & (df['month'] == 'Jan')]
df[df['status'] != 'cancelled']
df.query("amount > 100 and region == 'East'")

The brackets around each condition are not optional: & binds tighter than == in Python, so the version without them raises an error. Getting that wrong a few times is how it sticks.

Set 3: group

df.groupby('region')['amount'].sum()
df.groupby('region')['amount'].agg(['sum', 'mean', 'count'])
df.groupby(['region', 'month'])['amount'].sum()
df.groupby('status')['amount'].sum().sort_values(ascending=False)

Predict first. North is 200, South 250, East 450, West 150, and those four must add to 1,050. Checking a group total against the ungrouped total is the single most useful habit in this set.

Set 4: reshape

df.pivot_table(index='region', columns='month',
               values='amount', aggfunc='sum', fill_value=0)
df.sort_values('amount', ascending=False).head(3)
df.assign(is_big=df['amount'] >= 150)

Set 5: join

regions = pd.DataFrame({'region': ['North','South','East','Central'],
                        'manager': ['Alvarez','Brennan','Cho','Diaz']})

df.merge(regions, on='region', how='left')     # West gets NaN
df.merge(regions, on='region', how='inner')    # West disappears
df.merge(regions, on='region', how='outer')    # Central appears

This set is the most valuable one on the page. West is in the orders and not in the region list; Central is in the list and has no orders. Count the rows after each merge and say why the number changed before looking.

Set 6: write the answer to a question

Not a function, a question. Which region has the highest average order? Which month grew? What share of value is cancelled? Answer each in one chain, then check by hand.

df[df.status != 'cancelled'].groupby('region')['amount'].mean().idxmax()
Predict, then run. Writing the expected answer on paper before pressing run is what converts a drill from typing practice into learning. When you are wrong, you have found something you did not know, which is the whole return on the exercise.

Why typing rather than reading

Two things happen when you type that do not happen when you read. You have to retrieve the syntax rather than recognise it, and the interpreter tells you immediately when your model of it was wrong. Reading gives you neither: a notebook that runs cannot tell you which lines you could not have written.

It is also why frequency beats duration. Six twenty-minute sessions across a week produce six occasions of retrieval. One two-hour session produces one, and by Friday most of it is gone.

The four-week routine

WeekFocusSignal you are ready to move on
1Sets 1 to 3, from memoryYou can type a groupby without checking anything
2Add sets 4 and 5You can predict merge row counts correctly
3Same drills on a real CSV you downloadedYou survive the dtype and date problems
4Set 6 only, new question each dayYou reach for pandas before a spreadsheet

Week three is where most of the real learning happens, because real files have text in numeric columns, dates in three formats and a column named with a trailing space. Those are covered in read_csv and dates in pandas.

How to tell whether it worked

  1. Open a blank file and reproduce the table from memory. If you cannot, that is the first drill again.
  2. Write a groupby with two keys and an aggregation without any reference open.
  3. Predict the row count of a left merge and be right.
  4. Explain out loud why a chained filter needs its brackets.
  5. Answer a question in one chain that you could previously only answer in a spreadsheet.

How to apply this to your own work

  1. Put the eight-row table in a file you can open in one keystroke. Friction is what ends daily routines.
  2. Do set 1 on every real dataset you touch at work. It is the same drill with stakes.
  3. Keep a note of every error message you meet and what caused it. That note becomes your personal syllabus.
  4. Replace one recurring spreadsheet task with a script once you reach week three.
  5. Retype rather than copy, for at least the first month.

The one habit to keep

Predict the output before running the cell. It is the difference between practising the keyboard and practising the thinking, and only one of those transfers to a dataset you have never seen.

Could you rebuild that eight-row table right now, in a blank file, without looking?

Every number here was run before it was published. Region totals North 200, South 250, East 450, West 150, summing to the table total of 1,050.
Reading pandas is easy and remembering it is not. The gap between them is typing.

Python for Analysts is a working analyst pandas book: read a file, fix its types, group it, join it, and check the answer before anyone else sees it.

Python for Analysts, $19 →
One runnable line at a time.

SQL Drill runs the same idea for SQL in the browser, and the Python Kit covers the concepts each drill practises.

Open the Python Kit →