Skip to content

Commit

Permalink
Merge pull request #94 from ibm-granite/frequency_handling
Browse files Browse the repository at this point in the history
Fix some frequency handling issues
  • Loading branch information
wgifford authored Jul 31, 2024
2 parents 728f030 + 5fb1cd0 commit 1ec54d4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tsfm_public/toolkit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,16 +565,19 @@ def convert_tsf(filename: str) -> pd.DataFrame:
"seconds": "s",
"minutes": "min",
"minutely": "min",
"monthly": "MS",
"yearly": "YS",
"quarterly": "QS",
}

if frequency:
try:
freq_val, freq_unit = frequency.split("_")
freq = freq_val + tsf_to_pandas_freq_map[freq_unit]
except ValueError:
freq = tsf_to_pandas_freq_map(freq_val)
freq = tsf_to_pandas_freq_map[frequency]
except KeyError:
raise ValueError(f"Input file contains an unknow frequency unit {freq_unit}")
raise ValueError(f"Input file contains an unknown frequency unit {freq_unit}")
else:
freq = None

Expand All @@ -596,6 +599,7 @@ def convert_tsf(filename: str) -> pd.DataFrame:
)

df = pd.concat(dfs)
df.reset_index(inplace=True, drop=True)
return df


Expand Down

0 comments on commit 1ec54d4

Please sign in to comment.