Pandasdrill

Get fluent in pandas by writing it.

Pandasdrill is pandas practice in your browser. Every exercise shows you a small, realistic table and a task. You write Python in the editor, run it on real pandas, see your result as a table, and get it checked on the spot and again on a second dataset, so code that only fits the sample fails.

  • loc, iloc, boolean masks, isin and query
  • Missing values, astype, string methods and dates
  • groupby, named aggregations, pivot_table and crosstab
  • merge, concat, melt, pivot, stack and unstack
  • Rolling averages, pct_change, rank, shift and resample
  • cut, qcut and apply

45 exercises5 levels5 free, no sign-up

A laptop showing a grid of data next to a potted bamboo plant

Read the task, write the code, see the result.

  1. 01
    Look at the dataEach exercise shows its tables, so you know the columns and values before you start.
  2. 02
    Write pandasType in the editor and press Run to see your result as a table, with print output and readable errors.
  3. 03
    Check itWrong type, wrong shape, wrong columns, the first value that differs, or code that only fits the sample. Hints and a reference solution follow.

Five levels, from your first filter to resampling.

9Selecting and filteringColumns, loc and iloc, boolean masks, isin, between, query, sorting, head and nlargest.
9CleaningMissing values, astype, string methods like strip, contains and extract, duplicates, rename, replace and dates.
9Aggregatinggroupby with sum, mean and count, named aggregations, value_counts, pivot_table and crosstab.
9Combining and reshapingInner and left merges, keys with different names, concat, melt, pivot, stack and unstack.
9AnalysisRolling averages, pct_change, cumsum, rank, shift, monthly resampling, cut and qcut, apply with a function.

pandas practice that checks your result, not your wording

Most pandas tutorials show a snippet, let you run it on the tutorial's DataFrame and call that practice. A week later you still cannot write a groupby with two keys from scratch. Pandasdrill was built around one rule: the only way through an exercise is code that produces the right table.

Your code runs on the sample tables, and then again on a second dataset with different rows and values, and your result variable is compared with the expected answer each time. Code that hard-codes an index, or only works because the sample happens to be sorted, passes the first run and fails the second. If the answer is off, you are told whether the type, shape, columns or a specific value differs. Small differences such as int versus float do not count against you.

Learn pandas online, on real pandas, with nothing to install

Your code runs on real pandas inside your browser, through Pyodide, a version of Python built for the web. The first run downloads it, which takes about ten seconds; after that it is cached, and every run is instant. Nothing you type is executed on a server.

That makes it useful where setting up a notebook is awkward: between meetings, on a train, on a laptop without Python. Progress and your last code are saved in your browser, and a free account keeps them across devices.

pandas exercises built in five levels

The 45 exercises are organized into levels of nine, and each level only adds one or two ideas on top of what you already know.

  • Selecting and filtering: pick two columns, filter with a boolean mask, rows and columns with loc, position-based slicing with iloc, isin, between, query, sort by two columns, the top three earners.
  • Cleaning: fill missing values in one column, drop rows missing a key field, convert text to numbers, tidy text with strip and lower, search with str.contains, pull numbers out of codes, remove duplicates, rename and replace, dates with to_datetime.
  • Aggregating: total by group, group means as a flat table, count rows per group, named aggregations, group by two keys, a pivot table with a fill value, counts with crosstab, shares with value_counts, several statistics at once.
  • Combining and reshaping: inner merge, a left merge that keeps every order, merge on differently named keys, concat, merge twice then aggregate, melt, pivot, stack and unstack.
  • Analysis: a rolling average, month over month growth, running totals, rank with ties, change from the previous period, monthly totals with resample, quartile bins with qcut, age bands with cut, classify with apply.

Within a level the exercises get harder one notch at a time. By the end of Combining and reshaping you have done a left merge that keeps the orders with no customer, melted a wide table to long and pivoted it back, not because you read about it, but because the exercise would not pass until you did.

Open the exercise list

pandas groupby practice, the part everyone looks up

Ask anyone who uses pandas which syntax they search for every week and the answer is groupby: how to get a flat table instead of a MultiIndex, how to name the output columns, how to aggregate two columns two different ways. Pandasdrill gives groupby a level of its own, with exercises that go from a single sum to named aggregations and pivot_table with a fill value.

Each one is checked on a second dataset, so a reset_index you forgot or a column you hard-coded shows up before it would at work.

Python data analysis practice for people moving from Excel or SQL

If you already do this work in spreadsheets or SQL, every exercise has a familiar shape: a filter is a WHERE clause, a groupby is a pivot table, a merge is a VLOOKUP or a JOIN, a pivot_table is exactly what it sounds like. The tables are small and realistic: employees with departments and salaries, orders with customers and dates, products with categories and codes.

The tasks are the ones that land in an analyst's inbox: total by group, month over month growth, the top three, the rows with no match, the duplicates. Nothing is invented to pad the list.

Learn pandas by getting it wrong first

A hint is one click away, but the reference solution opens only after your second attempt. That is on purpose. Running your code, seeing that the shape differs because of a stray index level, and fixing it yourself is the part that sticks. Copying a solution before you have tried does not.

Every exercise also explains why the reference solution is built the way it is: why as_index=False gives a flat table, why a left merge is the safe default when counting, why resample needs a datetime index.

pandas interview questions, practiced under a clock

Data analyst and data scientist interviews often include a short pandas task: clean this column, aggregate by month, join these tables and find the gap. The questions are not hard once you have written them a few times. They are hard the first time, with someone watching.

Timed mode puts a clock on each exercise with hints and solutions locked until time is up. Run through the first four levels the week before an interview and the live task feels like one more drill.

Try a timed exercise

Why hands-on beats watching

You can watch a ten-minute video on merges and feel like you understand them. Then you open a notebook, type pd.merge( and stop at the how argument. The gap between recognizing and producing is the whole problem, and the only thing that closes it is reps.

A Pandasdrill session is five to fifteen minutes of writing code, each exercise slightly different from the last. Ten sessions in, the indexing rules, the groupby patterns and the reshaping verbs are automatic.

pandas exercises for beginners and for daily users

If you know some Python and have never used pandas, Selecting and filtering starts with picking two columns and does not assume anything else. If you use pandas every day, skip to Combining and reshaping or Analysis and look for the gaps: most people have one verb they have always avoided, usually melt, stack or resample, and the drills find it quickly.

Every exercise is independent, so you can jump to the one you need for today's problem and come back to the rest later.

Timed mode for real speed.Each exercise gets a clock. Hints and solutions stay locked until time is up, and your best times are kept.

The same questions in SQL.Our sister site Querydrill drills the same kind of analysis in SQL, with 60 exercises checked on changed data. Try Querydrill

Try the first five exercises free.

No sign-up needed for the first five. If it works for you, Pro unlocks all 45, and a free account saves your progress and your code across devices.

Start practicing free

Start free. Pay once you are hooked.

Free

$0
  • The first 5 exercises
  • Real pandas in your browser
  • Instant checking, hints and timed mode
Start free

Pro

All 45
  • Cleaning, groupby, merges, reshaping and time series
  • Reference solutions with explanations
  • Progress and best times saved to your account

You create a free account first, so Pro is attached to it.

Monthly is charged today and then every month until you cancel, in one click from your account page. Lifetime is one payment with no renewals. Full refund within 14 days of paying.

Questions

Who is this for?

Data analysts and students who know some Python and want pandas to feel natural: people moving over from Excel or SQL, and anyone who keeps looking up the same groupby syntax.

Do I need to install anything?

No. Your code runs on real pandas inside your browser, through Pyodide, a version of Python built for the web. The first run downloads it, which takes about 10 seconds; after that it is cached.

How is my code checked?

Your code runs on the sample tables, and then again on a second dataset with different rows and values, and your result variable is compared with the expected answer each time. Small differences like int versus float do not count against you. If the answer is off, you are told whether the type, shape, columns or a specific value differs.

Is there a free version?

The first five exercises are free without an account. Pro unlocks the other 40 for $12 a month or $59 once.

Do I need an account?

No. The free exercises work without one and save progress in your browser. A free account saves progress across devices, and Pro unlocks the rest.

How do I cancel the monthly plan?

Open Account and choose Cancel subscription. You keep Pro until the end of the period you paid for and are not charged again. If Pro is not for you, you get a full refund within 14 days of paying.

What if my answer is right but marked wrong?

Answers are checked on the result they produce, not on how they are written, so any correct code passes. If a check still gets it wrong, use the report link under the result. Reports are reviewed, and a check that is wrong gets fixed.