google-research / timesfm

TimesFM (Time Series Foundation Model) is a pretrained time-series foundation model developed by Google Research for time-series forecasting.
https://research.google/blog/a-decoder-only-foundation-model-for-time-series-forecasting/
Apache License 2.0
3.02k stars 228 forks source link

Cannot offset times with data type: 'dbdate' #50

Closed gte644q closed 1 month ago

gte644q commented 1 month ago

I was running the following code forecast_df = tfm.forecast_on_df( inputs=df, freq="D", # daily value_name="y", num_jobs=-1, ) It shows the following message 'Processing dataframe with multiple processes. Finished preprocessing dataframe. Finished forecasting. ' Then failed with this message 'ValueError: Cannot offset times with data type: 'dbdate' using a frequency of type: '<class 'pandas._libs.tslibs.offsets.Day'>'.'

baldwibr commented 1 month ago

Sounds like your 'ds' input is dbdate rather than a datetime64[ns] format which it expects. Convert the field type prior to running it through forecast_on_df.

df['ds'] = pd.to_datetime(df['ds'])
gte644q commented 1 month ago

It turns out that some days are missing values. Once I fixed the missing value, the error is gone now.