Compare commits
No commits in common. "0292db36e2f3c8ba09290ec6c6121773d2c72686" and "594ddbd7404e0e5f9dd22e4386de58d0481b097d" have entirely different histories.
0292db36e2
...
594ddbd740
25
wsgi.py
25
wsgi.py
@ -260,9 +260,8 @@ def convert_fig_to_svg(fig: plt.Figure) -> str:
|
|||||||
@app.route("/")
|
@app.route("/")
|
||||||
@cache.cached(query_string=True)
|
@cache.cached(query_string=True)
|
||||||
def tables():
|
def tables():
|
||||||
def _print_as_html(df: pd.DataFrame, total: int | None = None) -> None:
|
def _print_as_html(df: pd.DataFrame):
|
||||||
df = df.astype({"Digitale Befragung": "Int32"})
|
df = df.astype({"Digitale Befragung": "Int32"})
|
||||||
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,
|
||||||
@ -282,23 +281,9 @@ def tables():
|
|||||||
[
|
[
|
||||||
f" <td>{df['Digitale Befragung'].sum()}</td>",
|
f" <td>{df['Digitale Befragung'].sum()}</td>",
|
||||||
" </tr>",
|
" </tr>",
|
||||||
|
" </tfoot>",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
if total:
|
|
||||||
tfoot.extend([
|
|
||||||
" <tr>",
|
|
||||||
" <td>Weitere Bezirke</td>",
|
|
||||||
])
|
|
||||||
for i in range(len(df.columns) - 2):
|
|
||||||
tfoot.append(" <td></td>")
|
|
||||||
tfoot.extend(
|
|
||||||
[
|
|
||||||
f" <td>{total - df['Digitale Befragung'].sum()}</td>",
|
|
||||||
" </tr>",
|
|
||||||
]
|
|
||||||
)
|
|
||||||
tfoot.append(" </tfoot>")
|
|
||||||
|
|
||||||
tfoot = "\n".join(tfoot)
|
tfoot = "\n".join(tfoot)
|
||||||
idx = table.index("</table>")
|
idx = table.index("</table>")
|
||||||
output_str.append(table[: idx - 1])
|
output_str.append(table[: idx - 1])
|
||||||
@ -319,11 +304,7 @@ def tables():
|
|||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
_print_as_html(df_state)
|
_print_as_html(df_state)
|
||||||
|
_print_as_html(df)
|
||||||
df["Bundesland"] = df.index.map(get_landesbezirk)
|
|
||||||
df = df.rename(columns={"Bundesland": "Landesbezirk"})
|
|
||||||
|
|
||||||
_print_as_html(df, total=df_state['Digitale Befragung'].sum())
|
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"base.html",
|
"base.html",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user