Add current datapoint & format
This commit is contained in:
parent
a6325468ca
commit
3953d6d2ff
4
plot.py
4
plot.py
@ -13,7 +13,9 @@ def main(folder: str = "plots"):
|
|||||||
timestamp = timestamp.replace(":", "-")
|
timestamp = timestamp.replace(":", "-")
|
||||||
plot_df = create_plot_df(datetime.datetime.now(), _df_state)
|
plot_df = create_plot_df(datetime.datetime.now(), _df_state)
|
||||||
print(plot_df.sum(1))
|
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__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@ -10,23 +10,37 @@ import numpy as np
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
import scipy
|
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():
|
def create_dfs(url: str = "https://beschaeftigtenbefragung.verdi.de/"):
|
||||||
last_file = sorted(Path("data").iterdir())[-1]
|
try:
|
||||||
key = last_file.name[:10]
|
curr_datetime = datetime.datetime.now()
|
||||||
|
df, df_state = get_tables(url)
|
||||||
|
|
||||||
with (Path("data") / f"{key}_data.ods").open("rb") as ff:
|
df = df.sort_values(
|
||||||
df = pd.read_excel(ff, sheet_name="digital", index_col=0).astype(
|
["Digitale Befragung", "Bundesland", "Bezirk"],
|
||||||
{"Digitale Befragung": "Int32"}
|
ascending=[False, True, True],
|
||||||
)
|
|
||||||
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)
|
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
|
return df, df_state, plot_df
|
||||||
|
|
||||||
@ -108,7 +122,7 @@ def main():
|
|||||||
|
|
||||||
plt.gca().set_xticks([target_time])
|
plt.gca().set_xticks([target_time])
|
||||||
plt.title("Projektion Teilnahme an Digitaler Beschäftigtenbefragung")
|
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__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
2
wsgi.py
2
wsgi.py
@ -111,7 +111,7 @@ def plot(
|
|||||||
alpha: float | None = None,
|
alpha: float | None = None,
|
||||||
landesbez_str: str | None = None,
|
landesbez_str: str | None = None,
|
||||||
fix_lims: bool = True,
|
fix_lims: bool = True,
|
||||||
max_shading_date = None,
|
max_shading_date=None,
|
||||||
) -> str:
|
) -> str:
|
||||||
fig = plt.figure(dpi=300)
|
fig = plt.figure(dpi=300)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user