Skip to content

Commit

Permalink
#64 Linter changes
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickvorgers committed Oct 20, 2024
1 parent 9c84819 commit f3e0a54
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions Datasources/Enphase/EnphaseDataPrepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,33 @@ def customPrepareDataPre(dataFrame: pd.DataFrame) -> pd.DataFrame:
# Prepare the input data (after date/time manipulation)
def customPrepareDataPost(dataFrame: pd.DataFrame) -> pd.DataFrame:
if dataFrame["Energy Produced (Wh)"].dtype == "object":
dataFrame["Energy Produced (Wh)"] = dataFrame["Energy Produced (Wh)"].str.replace(",", "").replace("\"", "").astype(int)
if (("Exported to Grid (Wh)" in dataFrame.columns) and (dataFrame["Exported to Grid (Wh)"].dtype == "object")):
dataFrame["Exported to Grid (Wh)"] = dataFrame["Exported to Grid (Wh)"].str.replace(",", "").replace("\"", "").astype(int)
if (("Imported from Grid (Wh)" in dataFrame.columns) and (dataFrame["Imported from Grid (Wh)"].dtype == "object")):
dataFrame["Imported from Grid (Wh)"] = dataFrame["Imported from Grid (Wh)"].str.replace(",", "").replace("\"", "").astype(int)
dataFrame["Energy Produced (Wh)"] = (
dataFrame["Energy Produced (Wh)"]
.str.replace(",", "")
.replace('"', "")
.astype(int)
)
if ("Exported to Grid (Wh)" in dataFrame.columns) and (
dataFrame["Exported to Grid (Wh)"].dtype == "object"
):
dataFrame["Exported to Grid (Wh)"] = (
dataFrame["Exported to Grid (Wh)"]
.str.replace(",", "")
.replace('"', "")
.astype(int)
)
if ("Imported from Grid (Wh)" in dataFrame.columns) and (
dataFrame["Imported from Grid (Wh)"].dtype == "object"
):
dataFrame["Imported from Grid (Wh)"] = (
dataFrame["Imported from Grid (Wh)"]
.str.replace(",", "")
.replace('"', "")
.astype(int)
)

# Create a tariff column, uncomment the below lines if needed
#for index, _ in dataFrame.iterrows():
# for index, _ in dataFrame.iterrows():
# recordDateTime = pd.to_datetime(dataFrame.at[index, dateTimeColumnName], unit='s')
# # Check if it is Monday, Tuesday, Wednesday, Thursday or Friday
# if recordDateTime.weekday() in [0, 1, 2, 3, 4, 5]:
Expand Down

0 comments on commit f3e0a54

Please sign in to comment.