Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Analyze Categorical Data

pnmcdos on April 8, 2022

Why is it that we can print the variables without having to write print? Line 24 cat_totals for example. Is this a Jupyter functionality?

Bartosz Zaczyński RP Team on April 8, 2022

@pnmcdos It’s somewhat similar to a regular Python interpreter. When you run the python command, you’ll start an interactive Python interpreter session known as REPL (Read-Evaluate-Print Loop). It reads your commands, evaluates them, and prints the corresponding results immediately onto the screen.

It does so by calling repr() on the last evaluated expression, behind the scenes, in order to turn that expression into a textual representation. For example, a date object will have the following representation:

>>> from datetime import date
>>>, 4, 8)

It’s almost the same as if you called repr() against that object yourself:

>>> repr(
', 4, 8)'

The only difference is that the string will be enclosed in single quotes.

Now, when you call print() on something, in turn, it will call str() on that object for you, which might produce a slightly different textual representation:

>>> print(

>>> str(

Jupyter Notebooks take the same idea, but instead of producing textual output, they can leverage much more visually appealing representations thanks to running in a web browser, which often lets you interact with those representations. The specific representation will depend on the type of object at hand. In this case, the variable references a Pandas data frame object, which the notebook can display as tabular data.

Become a Member to join the conversation.