Extinct species

Tags: #iucn #opendata #extinctspecies #analytics #plotly
Author: Martin Delasalle​
Source :
If you want another view of the data : Link :


The initial aim was to compare the number of threatened species per species over time (e.g. number of pandas per year).
After a lot of research, it turns out that this kind of data is not available or it is only data from one year (2015 or 2018).
Therefore, we decided to start another project: Number of threatened species per year, with details by category using data from this site :
So we took the pdf from this site and turned it into a csv. But the data was heavy and not easy to use. Moreover, we thought that this would not necessarily be viable and adaptable over time.
So we decided to take another datasource on a similar subject : Extinct Species, from this website :
  • (only 2018)
  • (old Dataset, last upload was in 2015)
  • (the years are not available)
  • (apart from the case)
  • (we can't use it)
  • (no datas about threatened species)
  • (only about tigers but there are no datas usefull)


Import library

import pandas as pd
import as px

Setup your variables

👉 Download data in CSV and drop it on your root folder
# Input csv
csv_input = "Table 3 Species by kingdom and class - show all.csv"


Get data from csv

# We load the csv file
data = pd.read_csv(csv_input, ',')
# We set the column Name as index
data.set_index('Name', inplace = True)
# Then we select the columns EX, EW and Name, and all the lines we want in the graph
table = data.loc[["Total",
"OSTRACODA"]# add species here
# We add a new column 'CATEGORY' to our Dataframe
table["CATEGORY"] = ["Total",
table = table.loc[:,["CATEGORY","EX"]] # we drop the column "EW"
# ---NOTE : If you want to add new species, you have to also add his category
# We groupby CATEGORIES :
table.reset_index(drop=True, inplace=True)
table = table.groupby(['CATEGORY']).sum().reset_index()
table.rename(columns = {'EX':'Extincted'}, inplace=True)


Plot graph

# We use plotly to show datas with an horizontal bar chart
def create_barchart(table):
Graph = table.sort_values('Extincted', ascending=False)
fig =,
fig.update_layout(title_text="Number of species that have gone extinct since 1500",
text="Source : IUCN Red List of Threatened Species<br>",
return fig
fig = create_barchart(table)
Last modified 1mo ago