Gus (๐Ÿค–๐Ÿง +๐Ÿ+๐Ÿฅ‘๐Ÿ—ฃ๏ธ) Profile picture
AI Developer Advocate @google - Gemma ๐Ÿ’Ž - Machine Learning ๐Ÿค–๐Ÿง  - Google AI โš™๏ธ๐Ÿง  - DevRel ๐Ÿฅ‘๐Ÿ—ฃ๏ธ find me also at: https://t.co/3nrTwEKoJ0

Nov 11, 2021, 8 tweets

Did you know that you can apply styles to your Pandas visualization?

Let's take a brief look at it ๐Ÿ‘€

[1 min]
1/8๐Ÿงต

Now that you have loaded the data, it's very important to understand it.

To help with that it's good to be able to read it properly and formatting the data definitely help!

Let's come back to the New York Taxi fare

2/8๐Ÿงต

The fare amount is money.

To format a financial value in Python, we would use the string format "${15,.2f}"

Pandas has a style object and a very similar format method:

3/8๐Ÿงต

But how about that date column? We don't need all those zeros.

Let's just show a simple iso format. To do that we can use: strftime('%Y-%m-%d')

You can use a lambda function to apply that to the column (in a previous thread we already casted it to datetime)!

4/8๐Ÿงต

How big are the values compared to the average of the column? To know that, we can add some bars per cell!

This can give a good insight on the size of numerical values.

5/8๐Ÿงต

How about adding some more color.

The higher the value we will paint with a darker color
In our case green but you can use any of the Matplotlib colormap options

This can also be applied per row or per column

6/8๐Ÿงต

You usually will not see all your rows unless you have a very basic dataset.

Ideally you'd use this styling in one of the 2 use cases:

โ€ข A sample or projection of the data
โ€ข The descriptive statistics view (describe method)

7/8๐Ÿงต

To understand data you need all the help you can get, giving some visual clues to your eyes is very welcome! ๐Ÿ‘๏ธ๐Ÿ”

Don't forget to share this thread with your friends and let's make some colorful reports!

And if you're not following me yet, you're missing out!๐Ÿ˜‰

8/8๐Ÿงต

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling