profile

Learn Data Science from Data School ๐Ÿ“Š

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

Published about 1 year agoย โ€ขย 1 min read

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 Data Science from Data School ๐Ÿ“Š

Kevin Markham

Join 25,000+ aspiring Data Scientists and receive Python & Data Science tips every Tuesday!

Read more from Learn Data Science from Data School ๐Ÿ“Š

Hi Reader, happy Tuesday! My recent tips have been rather lengthy, so I'm going to mix it up with some shorter tips (like today's). Let me know what you think! ๐Ÿ’ฌ ๐Ÿ”— Link of the week A stealth attack came close to compromising the world's computers (The Economist) If you haven't heard about the recent "xz Utils backdoor", it's an absolutely fascinating/terrifying story! In short, a hacker (or team of hackers) spent years gaining the trust of an open-source project by making helpful...

13 days agoย โ€ขย 1 min read

Hi Reader, Today's tip is drawn directly from my upcoming course, Master Machine Learning with scikit-learn. You can read the tip below or watch it as a video! If you're interested in receiving more free lessons from the course (which won't be included in Tuesday Tips), you can join the waitlist by clicking here: Yes, I want more free lessons! ๐Ÿ‘‰ Tip #43: Should you discretize continuous features for Machine Learning? Let's say that you're working on a supervised Machine Learning problem, and...

20 days agoย โ€ขย 2 min read

Hi Reader, I'm so excited to share this week's tip with you! It has been in my head for months, but I finally put it in writing โœ๏ธ It's longer than usual, so if you prefer, you can read it as a blog post instead: Jupyter & IPython terminology explained ๐Ÿ”— Link of the week Python Problem-Solving Bootcamp (April 1-21) Want to improve your Python skills quickly? There's no better way than solving problems, reviewing alternative solutions, and exchanging ideas with others. That's the idea behind...

about 1 month agoย โ€ขย 3 min read
Share this post