in

Methods to Create Eye-Cathing Nation Rankings Utilizing Python and Matplotlib | by Oscar Leo | Aug, 2023


Matplotlib Tutorial

A phenomenal various to straightforward line charts

Chart created by the creator

Hello, and welcome to this tutorial, the place I’ll educate you to create the chart above utilizing Python and Matplotlib.

What I like about this knowledge visualization is its clear and exquisite means of displaying how international locations rank in contrast to one another on a selected metric.

The choice to utilizing a typical line chart displaying the precise values get messy if some international locations are shut to one another or if some international locations outperform others by rather a lot.

If you’d like entry to the code for this tutorial, yow will discover it on this GitHub repository.

Concerning the knowledge

I’ve created a easy CSV containing GDP values for as we speak’s ten largest economies for this tutorial.

Screenshot by the creator

The info comes from the World Bank, and the total identify of the indicator is “GDP (fixed 2015 us$)”.

If you wish to know extra about other ways of measuring GDP, you possibly can take a look at this story, the place I take advantage of the identical kind of knowledge visualization.

Let’s get on with the tutorial.

Step 1: Creating rankings

The first step is to rank the international locations for every year within the dataset, which is straightforward to do with pandas.

def create_rank_columns(df, columns):
rank_columns = ["rank_{}".format(i) for i in range(len(columns))]
for i, column in enumerate(columns):
df[rank_columns[i]] = df[column].rank(ascending=False)

return df, rank_columns

The ensuing columns appear to be this.


A Easy (But Efficient) Method to Implementing Unit Checks for dbt Fashions | by Mahdi Karabiben | Aug, 2023

Discovering Needles in a Haystack — Search Indexes for Jaccard Similarity | by Eric Zhù | Aug, 2023