Skip to content

Commit

Permalink
dev change
Browse files Browse the repository at this point in the history
  • Loading branch information
Yibei990826 committed Mar 15, 2024
1 parent 4ca9418 commit 79bfa22
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nbs/timegpt.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@
" df.index.name = time_col\n",
" df = df.reset_index()\n",
" else:\n",
" if hasattr(df.index, \"name\"):\n",
" if df.index.name == self.time_col:\n",
" try:\n",
" df.index = pd.to_datetime(df.index)\n",
" main_logger.info(\"Using datetime index as time column\")\n",
" except:\n",
" raise ValueError(f\"Dataframe index {self.time_col} is not of date type\")\n",
" df=df.reset_index()\n",
" self.freq = self.base_freq\n",
" renamer = {\n",
" self.id_col: 'unique_id',\n",
Expand Down
10 changes: 10 additions & 0 deletions nixtlats/timegpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ def transform_inputs(self, df: pd.DataFrame, X_df: pd.DataFrame):
df.index.name = time_col
df = df.reset_index()
else:
if hasattr(df.index, "name"):
if df.index.name == self.time_col:
try:
df.index = pd.to_datetime(df.index)
main_logger.info("Using datetime index as time column")
except:
raise ValueError(
f"Dataframe index {self.time_col} is not of date type"
)
df = df.reset_index()
self.freq = self.base_freq
renamer = {
self.id_col: "unique_id",
Expand Down

0 comments on commit 79bfa22

Please sign in to comment.