From 13d47be9c11ed09d7e70c57e52e69e1d9131ca83 Mon Sep 17 00:00:00 2001 From: Felix Blanke Date: Thu, 14 Sep 2023 11:05:57 +0200 Subject: [PATCH] Infer Bezirk value from total if only one entry is missing --- wsgi.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wsgi.py b/wsgi.py index fc9a356..aaa2dfb 100644 --- a/wsgi.py +++ b/wsgi.py @@ -292,8 +292,16 @@ def _print_as_html( ) -> list[str]: df = df.astype({"Digitale Befragung": "Int32"}) num_missing = (df[df.isna().any(axis=1)]["Landesbezirk"] != "Hessen").sum() + if num_missing == 1: + # infer value from total + df_tmp = df.loc[df["Landesbezirk"] != "Hessen"] + idx = df_tmp.loc[df_tmp.isna().any(axis=1)].iloc[0].name + df["Digitale Befragung"].loc[idx] = ( + total - df.dropna()["Digitale Befragung"].sum() + ) if dropna: df = df.dropna() + with pd.option_context("display.max_rows", None): table = df.to_html( index_names=False,