Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion dayliopy/fit_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ def prepare_data(df: pd.DataFrame) -> pd.DataFrame:
year. Therefore for simplicity, unique year values are split into one-hot
encoded columns, as with week and month.

e.g. weekday_1, weekday_7, month_1, month_12

We no longer set `verify_integrity=False` on the datetime index, as this
causes errors in the unlikely case that someone sets two records for the
same time. Which is okay as we only use the index for month and year.
See issue #25.

:param df: Cleaned input data.

:return df: Encoded data.
Expand All @@ -50,7 +57,7 @@ def prepare_data(df: pd.DataFrame) -> pd.DataFrame:

df["datetime"] = pd.to_datetime(df.datetime)

df.set_index("datetime", inplace=True, verify_integrity=True)
df.set_index("datetime", inplace=True)
df["month_num"] = df.index.month
df["year"] = df.index.year

Expand Down