From 65b63d1326f2e7be270034c200b9ad80e8976c23 Mon Sep 17 00:00:00 2001 From: mmaurostoffel <166130318+mmaurostoffel@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:59:16 +0100 Subject: [PATCH] =?UTF-8?q?Sortierung=20f=C3=BCr=20etl=5Fproperty=5Fcapaci?= =?UTF-8?q?ties=5Fmonthly=20eingef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- etl/src/data/etl_property_capacities_monthly.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/etl/src/data/etl_property_capacities_monthly.py b/etl/src/data/etl_property_capacities_monthly.py index 1fa78d6..a582af7 100644 --- a/etl/src/data/etl_property_capacities_monthly.py +++ b/etl/src/data/etl_property_capacities_monthly.py @@ -17,8 +17,11 @@ def property_capacities_monthly(id: int, scrapeDate: str): df_calendar = df_calendar.transpose() df_calendar = df_calendar.with_columns(pl.Series(name="dates", values=columnTitles)) df_calendar = df_calendar.with_columns((pl.col("dates").str.to_date())) - df_calendar = df_calendar.with_columns((pl.col("dates").dt.strftime("%b") + " " + (pl.col("dates").dt.strftime("%Y")))) + df_calendar = df_calendar.with_columns((pl.col("dates").dt.strftime("%b") + " " + (pl.col("dates").dt.strftime("%Y"))).alias('date_short')) + df_calendar = df_calendar.with_columns((pl.col("dates").dt.strftime("%Y") + " " + (pl.col("dates").dt.strftime("%m"))).alias('dates')) - df_calendar = df_calendar.group_by("dates").agg(pl.col("column_0").sum()) - result = {"scraping-date": scrapeDate, "months": df_calendar['dates'].to_list(), 'capacities': df_calendar['column_0'].to_list()} + df_calendar = df_calendar.group_by(['dates', 'date_short']).agg(pl.col("column_0").sum()) + df_calendar = df_calendar.sort('dates') + df_calendar = df_calendar.drop('dates') + result = {"scraping-date": scrapeDate, "months": df_calendar['date_short'].to_list(), 'capacities': df_calendar['column_0'].to_list()} return result \ No newline at end of file