Add current datapoint & format

This commit is contained in:
Felix Blanke 2023-09-12 16:42:56 +02:00
parent a6325468ca
commit 3953d6d2ff
3 changed files with 31 additions and 15 deletions

View File

@ -13,7 +13,9 @@ def main(folder: str = "plots"):
timestamp = timestamp.replace(":", "-")
plot_df = create_plot_df(datetime.datetime.now(), _df_state)
print(plot_df.sum(1))
fig.savefig(Path(folder) / f"digital_plot_{timestamp}.png", dpi=300, bbox_inches='tight')
fig.savefig(
Path(folder) / f"digital_plot_{timestamp}.png", dpi=300, bbox_inches="tight"
)
if __name__ == "__main__":

View File

@ -10,23 +10,37 @@ import numpy as np
import pandas as pd
import scipy
from wsgi import create_fig, create_plot_df, plot
from wsgi import create_fig, create_plot_df, get_tables, plot
def create_dfs():
last_file = sorted(Path("data").iterdir())[-1]
key = last_file.name[:10]
def create_dfs(url: str = "https://beschaeftigtenbefragung.verdi.de/"):
try:
curr_datetime = datetime.datetime.now()
df, df_state = get_tables(url)
with (Path("data") / f"{key}_data.ods").open("rb") as ff:
df = pd.read_excel(ff, sheet_name="digital", index_col=0).astype(
{"Digitale Befragung": "Int32"}
)
with (Path("data") / f"{key}_state_data.ods").open("rb") as ff:
df_state = pd.read_excel(ff, sheet_name="digital", index_col=0).astype(
{"Digitale Befragung": "Int32"}
df = df.sort_values(
["Digitale Befragung", "Bundesland", "Bezirk"],
ascending=[False, True, True],
)
plot_df = create_plot_df(None, None)
df_state = df_state.sort_values("Landesbezirk")
plot_df = create_plot_df(curr_datetime, df_state)
except Exception as e:
print(e)
last_file = sorted(Path("data").iterdir())[-1]
key = last_file.name[:10]
with (Path("data") / f"{key}_data.ods").open("rb") as ff:
df = pd.read_excel(ff, sheet_name="digital", index_col=0).astype(
{"Digitale Befragung": "Int32"}
)
with (Path("data") / f"{key}_state_data.ods").open("rb") as ff:
df_state = pd.read_excel(ff, sheet_name="digital", index_col=0).astype(
{"Digitale Befragung": "Int32"}
)
plot_df = create_plot_df(None, None)
return df, df_state, plot_df
@ -108,7 +122,7 @@ def main():
plt.gca().set_xticks([target_time])
plt.title("Projektion Teilnahme an Digitaler Beschäftigtenbefragung")
plt.savefig("plots/regression.png", bbox_inches='tight', dpi=300)
plt.savefig("plots/regression.png", bbox_inches="tight", dpi=300)
if __name__ == "__main__":

View File

@ -111,7 +111,7 @@ def plot(
alpha: float | None = None,
landesbez_str: str | None = None,
fix_lims: bool = True,
max_shading_date = None,
max_shading_date=None,
) -> str:
fig = plt.figure(dpi=300)