Infer Bezirk value from total if only one entry is missing
This commit is contained in:
parent
14e314822d
commit
13d47be9c1
8
wsgi.py
8
wsgi.py
@ -292,8 +292,16 @@ def _print_as_html(
|
|||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
df = df.astype({"Digitale Befragung": "Int32"})
|
df = df.astype({"Digitale Befragung": "Int32"})
|
||||||
num_missing = (df[df.isna().any(axis=1)]["Landesbezirk"] != "Hessen").sum()
|
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:
|
if dropna:
|
||||||
df = df.dropna()
|
df = df.dropna()
|
||||||
|
|
||||||
with pd.option_context("display.max_rows", None):
|
with pd.option_context("display.max_rows", None):
|
||||||
table = df.to_html(
|
table = df.to_html(
|
||||||
index_names=False,
|
index_names=False,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user