Compare commits

..

No commits in common. "65b63d1326f2e7be270034c200b9ad80e8976c23" and "2508b34ceb4743b35daf3a77054a0098102de947" have entirely different histories.

2 changed files with 9 additions and 16 deletions

View File

@ -17,11 +17,8 @@ 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"))).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.with_columns((pl.col("dates").dt.strftime("%b") + " " + (pl.col("dates").dt.strftime("%Y"))))
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()}
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()}
return result

View File

@ -8,7 +8,6 @@ d = data.load()
def property_capacities_weekdays(id: int, scrapeDate: str):
extractions = d.extractions_propId_scrapeDate(id, scrapeDate).pl()
weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
df_calendar = pl.DataFrame()
numWeeks = 0
@ -20,15 +19,12 @@ def property_capacities_weekdays(id: int, scrapeDate: str):
df_calendar = df_calendar.with_columns(pl.Series(name="dates", values=columnTitles))
df_calendar = df_calendar.with_columns((pl.col("dates").str.to_date()))
numWeeks = round((df_calendar.get_column("dates").max() - df_calendar.get_column("dates").min()).days / 7, 0)
df_calendar = df_calendar.with_columns(pl.col("dates").dt.weekday().alias("weekday_num"))
df_calendar = df_calendar.with_columns(pl.col("dates").dt.strftime("%A").alias("weekday"))
df_calendar = df_calendar.with_columns(pl.col("dates").dt.weekday().alias("weekday"))
df_calendar = df_calendar.drop("dates")
df_calendar = df_calendar.group_by(["weekday", "weekday_num"]).agg(pl.col("column_0").sum())
df_calendar = df_calendar.with_columns((pl.col("column_0") / numWeeks).alias("column_0"))
df_calendar = df_calendar.sort('weekday_num')
df_calendar = df_calendar.drop('weekday_num')
print(df_calendar)
df_calendar = df_calendar.group_by("weekday").agg(pl.col("column_0").sum())
df_calendar = df_calendar.with_columns((pl.col("column_0") / numWeeks).alias("weekday"))
result = {"scraping-date": scrapeDate, "weekday": df_calendar['weekday'].to_list(), 'capacities': df_calendar['column_0'].to_list()}
return result
return result