Skip to content

Instantly share code, notes, and snippets.

@niftycode
Last active Jun 19, 2021
Embed
What would you like to do?
Traffic Accidents in Kiel
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
kiel_unfaelle.py
version: 1.3
last edited: June 19th, 2021
The data is provided by the City of Kiel, Germany:
http://kiel.de/rathaus/statistik/open_data/index.php?id=de-sh-kiel_gesetze_justiz_strassenverkehsunfaelle_verkehrstote_verletzte_fahrerflucht
"""
import pandas as pd
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
df = pd.read_csv("kiel_unfaelle.csv", sep=";")
# print the first five rows
print(df.head())
x = df['Jahr']
y = df['Unfaelle']
plt.title("Traffic Accidents in Kiel", size="x-large")
plt.ylabel("Quantity", size="x-large")
plt.xlabel("Year", size="x-large")
plt.plot(y, "*-", markersize=6, linewidth=1, color='b', label="Traffic Accidents")
plt.legend(loc=(0.4, 0.8))
ax.set_xticks(range(len(x)))
ax.set_xticklabels(x, rotation='vertical')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment