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.