feat: added auswertung.py - processes the files and produces a plot

This commit is contained in:
Dominik Stolte 2025-10-31 15:08:50 +01:00
parent 970fa8c585
commit 23293629a0

51
auswertung.py Normal file
View file

@ -0,0 +1,51 @@
import pandas as pd
import os
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.DataFrame()
df["Standort"] = []
abkuerzungen = {
"Brandenburgische Technische Universität Cottbus-Senftenberg": "BTU Cottbus-Senftenberg",
"Bergische Universität Wuppertal": "BU Wuppertal",
"Christian-Albrechts-Universität zu Kiel": "CAU Kiel",
"Fachhochschule St. Pölten (AUT)": "FH St. Pölten",
"Universität Magdeburg": "OVGU Magdeburg",
}
# Einlesen aller Dateien im Ordner /data
files = os.listdir('data')
for fil in files:
data = pd.read_csv('data/' + fil)
data = data[["Standort","Status"]]
data = data.groupby(["Standort"]).count()
data = data.reset_index()
data[fil.strip(".csv")] = data["Status"]
data.drop(columns=["Status"], inplace=True)
df = pd.merge(df, data, on="Standort", how="outer")
df["Standort"] = df["Standort"].map(abkuerzungen).fillna(df["Standort"])
#df.to_csv('auswertung.csv', index=False)
# Umwandlung in ein Pivot-Format für eine Heatmap
df_heatmap = df.set_index("Standort").fillna(0)
# Plot anpassen: quadratische Zellen und Farbskala, die 0 von 1 abhebt
plt.figure(figsize=(0.6 * df_heatmap.shape[1], 0.6 * df_heatmap.shape[0]))
sns.heatmap(
df_heatmap,
cmap="coolwarm", # Farbpalette für besseren Kontrast zwischen 0 und 1
square=True, # Erzwingt quadratische Zellen
cbar_kws={'label': 'Anzahl der Teilnehmer'} # Beschriftung der Farbleiste
)
plt.title("Anzahl der Teilnehmer pro Standort und Tagung")
plt.xlabel("Tagung")
plt.ylabel("Standort")
# Achsenticks anpassen
plt.xticks(rotation=45, ha="right", fontsize=6) # Schriftgröße und Ausrichtung der x-Achse anpassen
plt.yticks(fontsize=8) # Schriftgröße der y-Achse anpassen
plt.show()