Skip to content

Instantly share code, notes, and snippets.

@niftycode
Last active June 19, 2021 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niftycode/b39a9c86c57324bbbbae18071c82a176 to your computer and use it in GitHub Desktop.
Save niftycode/b39a9c86c57324bbbbae18071c82a176 to your computer and use it in GitHub Desktop.
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