From aaf4ee1863ebbb1c92350211db149de4672a757c Mon Sep 17 00:00:00 2001 From: Felix Blanke Date: Fri, 1 Sep 2023 14:46:58 +0200 Subject: [PATCH] Add option to not drop NA --- wsgi.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wsgi.py b/wsgi.py index 087cc6f..119c801 100644 --- a/wsgi.py +++ b/wsgi.py @@ -264,9 +264,10 @@ def convert_fig_to_svg(fig: plt.Figure) -> str: return imgdata.read() -def _print_as_html(df: pd.DataFrame, output_str: list[str], total: int | None = None) -> list[str]: +def _print_as_html(df: pd.DataFrame, output_str: list[str], total: int | None = None, dropna: bool = True) -> list[str]: df = df.astype({"Digitale Befragung": "Int32"}) - df = df.dropna() + if dropna: + df = df.dropna() with pd.option_context("display.max_rows", None): table = df.to_html( index_names=False, @@ -328,7 +329,7 @@ def tables(): df = df.rename(columns={"Bundesland": "Landesbezirk"}) output_str = [] - output_str = _print_as_html(df_state, output_str) + output_str = _print_as_html(df_state, output_str, dropna=False) output_str = _print_as_html(df, output_str, total=df_state['Digitale Befragung'].sum()) return render_template(