pprint: Data pretty printer:

pprint is a beneficial built-in module in Python for Data Science. The pprint module helps us to “pretty print” arbitrary data structures in Python in a well formatted and readable way.

The below example will make things clear.

python for data science

The code given above is for getting geocode information of some place using Google Maps API in JSON format.

The output is not properly indented, and it affects the readability for nested data structures. Now we will look at an example.

In the above example, we imported the pprint function of pprint module. We use the pprint() function here rather than the print function.

If you want to learn more about pprint function in python for data science then you can check this and this as well.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.