Tuesday Tip #5: Visualize your pandas code ๐Ÿผ


Hi Reader!

Todayโ€™s tip is most useful if you already have some experience with pandas, which is the main data analysis library in Python.

If youโ€™re brand new to pandas, I recommend starting here:

๐Ÿ”— Easier data analysis with pandas (my free video series)

Letโ€™s move on to today's tip!


๐Ÿ‘‰ Tip #5: Visualize your code with Pandas Tutor

In order to progress from pandas beginner to intermediate (and beyond), itโ€™s important to build a mental model of what happens when you run your pandas code.

If youโ€™re struggling to build that mental model, Pandas Tutor might be the perfect tool for you!

For example, if you input code like this:

dogs.groupby('size').mean()

Pandas Tutor outputs a diagram like this:

โ€‹Interact with the live diagramโ€‹

Or if you input more complex code like this:

titanic.groupby(['Embarked', 'Sex'])['Pclass'].mean().unstack()

Pandas Tutor outputs a multi-step diagram like this:

โ€‹Interact with the live diagramโ€‹

If you want to explore further, scroll to the bottom of Pandas Tutor and click on one of the many examples.

Once youโ€™ve understood an example, Iโ€™d encourage you to change the code and/or the data, and see if the diagram changes in the way that you expect.

You can even paste in your own data! Just open up any CSV file, copy the top few rows (including the header), and paste them in place of the multi-line "csv" string:

Related Projects

โ€‹Tidy Data Tutor is very similar, except itโ€™s for R code and the Tidyverse.

โ€‹Python Tutor was created by the same author, and it allows you to visualize Python, JavaScript, C, C++, and Java code.

โ€‹nbtutor is a Jupyter Notebook extension for visualizing Python code within your notebook.

How helpful was todayโ€™s tip?

โ€‹๐Ÿคฉโ€‹๐Ÿ™‚โ€‹๐Ÿ˜โ€‹


If you enjoyed this issue, please forward it to a friend! Takes only a few seconds, and it really helps me out ๐Ÿ™

See you next Tuesday!

- Kevin

P.S. Whoa, you trained a neural net!

Did someone awesome forward you this email? Sign up here to receive data science tips every week!

Learn Artificial Intelligence from Data School ๐Ÿค–

Join 25,000+ intelligent readers and receive AI tips every Tuesday!

Read more from Learn Artificial Intelligence from Data School ๐Ÿค–

Hi Reader, On Friday, I announced my forthcoming book, Master Machine Learning with scikit-learn. In response, my Dad asked me: How does the subject of this book relate to Artificial Intelligence? In other words: What's the difference between AI and Machine Learning? Ponder that question for a minute, then keep reading to find out how I answered my Dad... ๐Ÿ‘‡ AI vs Machine Learning Here's what I told my Dad: You can think of AI as a field dedicated to creating intelligent systems, and Machine...

Hi Reader, Yesterday, I posted this announcement on LinkedIn and Bluesky and X: Kevin Markham @justmarkham Dream unlocked: I'm publishing my first book! ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰ It's called "Master Machine Learning with scikit-learn: A Practical Guide to Building Better Models with Python" Download the first 3 chapters right now: ๐Ÿ‘‰ https://dataschool.kit.com/mlbook ๐Ÿ‘ˆ Thanks for your support ๐Ÿ™ 1:47 PM โ€ข Sep 11, 2025 1 Retweets 5 Likes Read 1 replies This has been a dream of mine for many years, and I'm so excited...

Hi Reader, Hope youโ€™ve had a nice summer! โ˜€๏ธ As for me, Iโ€™ve been finishing my first ever book! I canโ€™t wait to tell you about it and invite you to be part of the launchโ€ฆ stay tuned ๐Ÿ‘€ Today's email focuses on a single important topic: AIโ€™s impact on your mental health ๐Ÿง  Read more below! ๐Ÿ‘‡ Sponsored by: Morning Brew The 5-Minute Newsletter That Makes Business Make Sense Business news doesn't have to be dry. Morning Brew gives you the biggest stories in business, tech, and finance with quick...