Offenbach Nationalities 2000–2017: A Bar Chart Race
Published:
An animated bar chart race showing how the nationality composition of Offenbach am Main shifted between 2000 and 2017. The data comes from the city’s statistical yearbooks (Statistische Jahrbücher), showing the top 10 nationalities per year by total population (men + women).
Offenbach consistently has one of the highest foreign population shares of any German city, often above 30%.
Code
The bar_chart_race library makes this fairly painless once the data is pivoted correctly:
import bar_chart_race as bcr
import pandas as pd
df = pd.read_csv("nationalities.csv")
pivot = df.pivot(index='jahr', columns='land', values='gesamt')
bcr.bar_chart_race(
df=pivot,
filename='nationalities_race.mp4',
title='Nationalities in Offenbach am Main',
n_bars=10,
period_length=1500,
steps_per_period=30
)
The CSV has columns land (country), m/w (male/female), gesamt (total), anteil (share), and jahr (year). FFmpeg is required for video encoding.