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, This week, I've got a short tip about AI agents, followed by some Data School news... ๐Ÿ‘‰ Tip #56: What are AI agents? Google is calling 2025 "the agentic era," DeepLearning.AI says "the agentic era is upon us," and NVIDIA's founder says "one of the most important things happening in the world of enterprise is agentic AI." Clearly AI agents are a big deal, but what exactly are they? Simply put, an AI agent is an application that uses a Large Language Model (LLM) to control its...

Hi Reader, Last week, I launched a brand new course: Build an AI chatbot with Python. 120+ people enrolled, and a few have already completed the course! ๐Ÿ‘ Want to join us for $9? ๐Ÿ‘‰ Tip #55: Should you still learn to code in 2025? Youโ€™ve probably heard that Large Language Models (LLMs) are excellent at writing code: They are competitive with the best human coders. They can create a full web application from a single prompt. LLM-powered tools like Cursor and Copilot can autocomplete or even...

Hi Reader, The Python 14-Day Challenge starts tomorrow! Hope to see you there ๐Ÿคž ๐Ÿ‘‰ Tuesday Tip: My top 5 sources for keeping up with AI I'll state the obvious: AI is moving incredibly FAST ๐Ÿ’จ Here are the best sources I follow to keep up with the most important developments in Artificial Intelligence: The Neuron (daily newsletter) My top recommendation for a general audience. Itโ€™s fun, informative, and well-written. It includes links to the latest AI news and tools, but the real goldmine is...