Pandas: Pandas Tutor – DZone Web Dev

This article focuses on the excellent tool for learning and troubleshooting the Pandas program known as “Pandas Tutor”. The “Pandas Tutor” tool visualizes how the Pandas code transforms the data, which helps to learn Pandas quickly, and we can also very effectively use this tool to debug our programs. It’s a great tool and visualization is super awesome, let’s learn this tool by performing a few basic Pandas programs.

To access Pandas Tutor online, please use this link.

Data setup

Set up the data first, for convenience we make our own dictionary and make a DataFrame from it.

Once the dictionary is created and the DataFrame is created, we need to click on the button “Visualize the expression of the pandas on the last line”, after which we can see that the tool performs “df.head ()” and produces the input given to the program and the output it generated. On this data we will perform all our basic operations and try to visualize the transformation.


Let’s perform a basic filter operation where we will see all the employees whose age is under 40 years.

Screenshot - 2

Incredibly, the operation is performed on the last line, which is “df[df[‘Age’] <40]”look at the input provided to the program and how the filtering transformation is performed and the output generated. The tool indicates with an arrow that employee 'David' is not drawn in the result DataFrame.

Transformation – Sorting

Let’s sort the DataFrame by a single column ‘Age’, and let’s see what kind of visualization tool performs,

Screenshot - 3

We sort the Age column in ascending order, “panda tutor” takes care of small details by highlighting the column on which the sorting is performed, and the arrows indicate the index for each row after sorting.

Let’s try sorting DataFrame by several columns:

Screenshot - 4

Two relevant columns are highlighted.

Transformation – nunique

“nunique” is a simple function that returns the number of unique values ​​in each column of the DataFrame. If it’s so simple an operation, why I then highlight that in the article is the reason “panda tutor” shows that the “Series” object is returned by the operation, to learn Panda’s return type is important, especially series.

Screenshot - 5

Transformation – group city

Let’s count the total number of employees in each department, we will use the groupby function in the “Department” column of the DataFrame.

Screenshot - 6

Using value_counts:

Screenshot - 7

I highly recommend “Pandas Tutor”, if you are a beginner or experienced, I wish I would have known about the tool earlier, it is useful whether we are learning Pandas or trying to debug an existing Pandas program.

I hope you find the article useful, thanks for reading.


Leave a Reply

Your email address will not be published.