Create a Racing Bar Chart in Python

...in just a couple of lines of code.

Do you have the skills to develop high-quality Python projects?

Take this 2-minute assessment I have prepared for you to find out.

There are 21 yes/no or rating-based questions to evaluate you on 7 key areas of Python project development:

At the end, you will receive a customized report with clear action items on how to improve:

Start the assessment here:

A big thanks to Sourcery.ai, a coding assistant that I have been using for over a year, who partnered with me in preparing this assessment.

Let’s get to today’s post!

Racing Bar Chart

I often come across the racing bar charts in many LinkedIn posts.

I am sure you would have seen them too.

It is an elegant animation that depicts the progress of multiple categories over time.

I always wondered how one can create them in Python.

Turns out, there’s a pretty simple way to do it just a couple of lines of Python code using Bar-chart-race library.

To create a racing bar chart, you can use its bar_chart_race() method.

The input must be a Pandas DataFrame:

  • Every row should represent a specific period of time

  • Each column should hold the value for a particular category

  • The index may contain the time component

After aligning the DataFrame in the desired format, you can create the racing bar chart as follows:

This will generate the racing bar chart right in your Jupyter notebook.

Isn’t that cool?

👉 Over to you: What other charts do you love creating in Python?

Thanks for reading!

  • 1 Referral: Unlock 450+ practice questions on NumPy, Pandas, and SQL.

  • 2 Referrals: Get access to advanced Python OOP deep dive.

  • 3 Referrals: Get access to the PySpark deep dive for big-data mastery.

Get your unique referral link:

Are you preparing for ML/DS interviews or want to upskill at your current job?

Every week, I publish in-depth ML deep dives. The topics align with the practical skills that typical ML/DS roles demand.

Join below to unlock all full articles:

Here are some of the top articles:

Join below to unlock all full articles:

👉 If you love reading this newsletter, share it with friends!

👉 Tell the world what makes this newsletter special for you by leaving a review here :)

Reply

or to participate.