Format
This commit is contained in:
parent
a0daed66ad
commit
40c30fdde8
34
wsgi.py
34
wsgi.py
@ -14,7 +14,12 @@ import pandas as pd
|
||||
from flask import Flask, Markup, abort, render_template, request
|
||||
from flask_caching import Cache
|
||||
|
||||
from download_digital import construct_dataframe, get_bez_data, get_landesbezirk, landesbezirk_dict
|
||||
from download_digital import (
|
||||
construct_dataframe,
|
||||
get_bez_data,
|
||||
get_landesbezirk,
|
||||
landesbezirk_dict,
|
||||
)
|
||||
|
||||
config = {
|
||||
"CACHE_TYPE": "FileSystemCache",
|
||||
@ -278,7 +283,12 @@ 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, dropna: bool = True) -> 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"})
|
||||
if dropna:
|
||||
df = df.dropna()
|
||||
@ -303,11 +313,13 @@ def _print_as_html(df: pd.DataFrame, output_str: list[str], total: int | None =
|
||||
" </tr>",
|
||||
]
|
||||
)
|
||||
if total and (diff := total - df['Digitale Befragung'].sum()):
|
||||
tfoot.extend([
|
||||
" <tr>",
|
||||
" <td>Weitere Bezirke</td>",
|
||||
])
|
||||
if total and (diff := total - df["Digitale Befragung"].sum()):
|
||||
tfoot.extend(
|
||||
[
|
||||
" <tr>",
|
||||
" <td>Weitere Bezirke</td>",
|
||||
]
|
||||
)
|
||||
for i in range(len(df.columns) - 2):
|
||||
tfoot.append(" <td></td>")
|
||||
tfoot.extend(
|
||||
@ -353,7 +365,9 @@ def state_dashboard(state: str):
|
||||
|
||||
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(), dropna=False)
|
||||
output_str = _print_as_html(
|
||||
df, output_str, total=df_state["Digitale Befragung"].sum(), dropna=False
|
||||
)
|
||||
|
||||
return render_template(
|
||||
"base.html",
|
||||
@ -381,7 +395,9 @@ def dashboard():
|
||||
|
||||
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())
|
||||
output_str = _print_as_html(
|
||||
df, output_str, total=df_state["Digitale Befragung"].sum()
|
||||
)
|
||||
|
||||
return render_template(
|
||||
"base.html",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user