Sortierung für etl_property_capacities_monthly eingefügt
parent
a6cbe3bc29
commit
65b63d1326
|
@ -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
|
Loading…
Reference in New Issue