#!/usr/bin/env python3 from pandas import read_csv import matplotlib.pyplot as plt import matplotlib.ticker as mtick import matplotlib as mpl mpl.rcParams['figure.dpi'] = 1200 import numpy as np import pathlib class display: def __init__(self, filename) -> None: """Start the actual import process. Seperates process and setup.""" with open(filename, mode='r', encoding='utf-8-sig', newline='') as csv_file: years = np.array([2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024]) styles = ["roenom", "roereal", "roetaxed", "realefftax"] cols = [f"{style}{year}" for style in styles for year in years] reader = read_csv(csv_file, usecols=cols, dtype=np.float32, low_memory=True) plt.style.use('_mpl-gallery') for style in styles: style_cols = [f"{style}{year}" for year in years] fig, ax = plt.subplots(figsize=(12, 6)) data = reader[style_cols].dropna(how='all', axis=1) data_list = [] data_list = [data[col].dropna().values for col in style_cols if col in data.columns] ax.boxplot(data_list, positions=years[:len(data_list)], patch_artist=True, showmeans=False, showfliers=False, medianprops={"color": "white", "linewidth": 0.5}, boxprops={"facecolor": "C0", "edgecolor": "white", "linewidth": 0.5}, whiskerprops={"color": "C0", "linewidth": 1.5}, capprops={"color": "C0", "linewidth": 1.5}) ax.yaxis.set_major_formatter(mtick.PercentFormatter(1.0)) plt.figtext(0.5, 0.01, style, ha='center', va='bottom') plt.show() display(pathlib.Path('/home/user/bachelorarbeit_importer/data/', 'cleaned_st_neu_verlustausschluss.csv'))