Skip to content

Commit

Permalink
Merge pull request #19 from airboxlab/upgrade-werkzeug
Browse files Browse the repository at this point in the history
Upgrade werkzeug
  • Loading branch information
antoine-galataud authored Oct 31, 2023
2 parents 223bd92 + af649cc commit a1e3486
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
16 changes: 7 additions & 9 deletions grafener/energyplus.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import logging
import os
from datetime import datetime, timedelta
from typing import Optional

Expand All @@ -8,8 +6,7 @@


def process_csv(df: DataFrame, sim_year: int) -> DataFrame:
"""
applies necessary transformations to E+ csv output
"""Applies necessary transformations to E+ csv output.
:param df:
:param sim_year:
Expand All @@ -18,7 +15,8 @@ def process_csv(df: DataFrame, sim_year: int) -> DataFrame:
# make a nice datetime format out of Date/Time column
output = df.copy()
output["Date/Time"] = output["Date/Time"].apply(
lambda strd: process_energyplus_datetime(strdate=strd, sim_year=sim_year))
lambda strd: process_energyplus_datetime(strdate=strd, sim_year=sim_year)
)
output["Date/Time"] = pd.to_datetime(output["Date/Time"], format="%Y/%m/%d %H:%M:%S", utc=True)
output.index = output["Date/Time"]
# last column has a trailing space
Expand All @@ -41,13 +39,13 @@ def process_energyplus_datetime(strdate: str, sim_year: int) -> str:
:return:
"""
if month := is_month_full_name(strdate):
return "{:04d}/{:02d}/{:02d} 00:00:00".format(sim_year, month.month, 1)
return f"{sim_year:04d}/{month.month:02d}/{1:02d} 00:00:00"
elif "24:00" in strdate:
date = strdate.strip().split(" ")[0]
new_date = datetime.strptime(date, "%m/%d") + timedelta(days=1)
return "{:04d}/{:02d}/{:02d} 00:00:00".format(sim_year, new_date.month, new_date.day)
return f"{sim_year:04d}/{new_date.month:02d}/{new_date.day:02d} 00:00:00"
else:
concat = "{:04d}/{}".format(sim_year, strdate.strip())
concat = f"{sim_year:04d}/{strdate.strip()}"
# manage 'daily' reporting frequency
if " " not in concat:
concat += " 00:00:00"
Expand All @@ -56,6 +54,6 @@ def process_energyplus_datetime(strdate: str, sim_year: int) -> str:

def is_month_full_name(strdate: str) -> Optional[datetime]:
try:
return datetime.strptime(strdate, '%B')
return datetime.strptime(strdate, "%B")
except ValueError:
return None
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
flask~=2.2.5
flask~=3.0.0
flask-cors~=3.0.10
pandas~=2.0.1
boto3~=1.13
Werkzeug~=2.2.2
Werkzeug~=3.0.1
attrs~=22.1.0
pyarrow~=9.0.0
pyarrow~=9.0.0

0 comments on commit a1e3486

Please sign in to comment.