Nixtla / nixtlar

R SDK for TimeGPT
https://nixtla.github.io/nixtlar/
Apache License 2.0
8 stars 2 forks source link

Hourly data vanishing when converted to character format #8

Open MMenchero opened 1 week ago

MMenchero commented 1 week ago

Description

A user reported the following issue:

When using a data frame or a tsibble, if the date column contains hourly data that is a datetime object, nixtlar will transform said column to characters. However, dates of the form yyyy-mm-dd 00:00:00 are converted to yyyy-mm-dd. This generates an error.

Reproducible example

library(nixtlar)
nixtlar::nixtla_set_api_key("NIXTLA_API_KEY")

df <- nixtlar::electricity 
nixtlar::nixtla_client_forecast(df, h=8, id_col="unique_id") # this works fine 

df$ds <- as.POSIXct(df$ds, format = "%Y-%m-%d %H:%M:%S") # this is the data type the user had

df#ds <- as.character(df$ds) # this is what `nixtlar` is doing in the background
head(df) 

nixtlar::nixtla_client_forecast(df, h=8, id_col="unique_id) # this returns an error