Data Requirements Suggest Edits This section explains the data requirements for TimeGPT . TimeGPT accepts pandas dataframes in long format with the following necessary columns: ds (timestamp): timestamp in format YYYY-MM-DD or YYYY-MM-DD HH:MM:SS . y (numeric): The target variable to forecast. (Optionally, you can also pass a DataFrame without the ds column as long as it has DatetimeIndex) TimeGPT also works with distributed dataframes like dask , spark and ray . You can also include exogenous features in the DataFrame as additional columns. For more information, follow this tutorial . Below is an example of a valid input dataframe for TimeGPT . Python import pandas as pd df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/air_passengers.csv') df.head() timestampvalue01949-01-0111211949-02-0111821949-03-0113231949-04-0112941949-05-01121 Note that in this example, the ds column is named timestamp and the y column is named value. You can either: Rename the columns to ds and y, respectively, or Keep the current column names and specify them when using any method from the NixtlaClient class with the time_col and target_col arguments. For example, when using the forecast method from the NixtlaClient class, you must instantiate the class and then specify the columns names as follows. Python from nixtla import NixtlaClient nixtla_client = NixtlaClient( api_key = 'my_api_key_provided_by_nixtla' Python fcst = nixtla_client.forecast(df=df, h=12, time_col='timestamp', target_col='value') fcst.head() INFO:nixtla.nixtla_client:Validating inputs... INFO:nixtla.nixtla_client:Preprocessing dataframes... INFO:nixtla.nixtla_client:Inferred freq: MS INFO:nixtla.nixtla_client:Calling Forecast Endpoint... timestampTimeGPT01961-01-01437.83792111961-02-01426.06271421961-03-01463.11654731961-04-01478.24450741961-05-01505.646484 In this example, the NixtlaClient is infereing the frequency, but you can explicitly specify it with the freq argument. To learn more about how to instantiate the NixtlaClient class, refer to the TimeGPT Quickstart Multiple Series If you’re working with multiple time series, make sure that each series has a unique identifier. You can name this column unique_id or specify its name using the id_col argument when calling any method from the NixtlaClient class. This column should be a string, integer, or category. In this example, we have five series representing hourly electricity prices in five different markets. The columns already have the default names, so it’s unnecessary to specify the id_col, time_col, or target_col arguments. If your columns have different names, specify these arguments as required. Python df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short.csv') df.head() unique_iddsy0BE2016-10-22 00:00:0070.001BE2016-10-22 01:00:0037.102BE2016-10-22 02:00:0037.103BE2016-10-22 03:00:0044.754BE2016-10-22 04:00:0037.10 Python fcst = nixtla_client.forecast(df=df, h=24) # use id_col, time_col and target_col here if needed. fcst.head() INFO:nixtla.nixtla_client:Validating inputs... INFO:nixtla.nixtla_client:Preprocessing dataframes... INFO:nixtla.nixtla_client:Inferred freq: H INFO:nixtla.nixtla_client:Calling Forecast Endpoint... unique_iddsTimeGPT0BE2016-12-31 00:00:0045.1904531BE2016-12-31 01:00:0043.2444462BE2016-12-31 02:00:0041.9583893BE2016-12-31 03:00:0039.7964864BE2016-12-31 04:00:0039.204536 When working with a large number of time series, consider using a distributed computing framework to handle the data efficiently. TimeGPT supports frameworks such as Spark, Dask, and Ray. Exogenous Variables TimeGPT also accepts exogenous variables. You can add exogenous variables to your dataframe by including additional columns after the y column. Python df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short-with-ex-vars.csv') df.head() unique_iddsyExogenous1Exogenous2day_0day_1day_2day_3day_4day_5day_60BE2016-10-22 00:00:0070.0049593.057253.00.00.00.00.00.01.00.01BE2016-10-22 01:00:0037.1046073.051887.00.00.00.00.00.01.00.02BE2016-10-22 02:00:0037.1044927.051896.00.00.00.00.00.01.00.03BE2016-10-22 03:00:0044.7544483.048428.00.00.00.00.00.01.00.04BE2016-10-22 04:00:0037.1044338.046721.00.00.00.00.00.01.00.0 When using exogenous variables, you also need to provide its future values. Python future_ex_vars_df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short-future-ex-vars.csv') future_ex_vars_df.head() unique_iddsExogenous1Exogenous2day_0day_1day_2day_3day_4day_5day_60BE2016-12-31 00:00:0064108.070318.00.00.00.00.00.01.00.01BE2016-12-31 01:00:0062492.067898.00.00.00.00.00.01.00.02BE2016-12-31 02:00:0061571.068379.00.00.00.00.00.01.00.03BE2016-12-31 03:00:0060381.064972.00.00.00.00.00.01.00.04BE2016-12-31 04:00:0060298.062900.00.00.00.00.00.01.00.0 Python fcst = nixtla_client.forecast(df=df, X_df=future_ex_vars_df, h=24) fcst.head() INFO:nixtla.nixtla_client:Validating inputs... INFO:nixtla.nixtla_client:Preprocessing dataframes... INFO:nixtla.nixtla_client:Inferred freq: H INFO:nixtla.nixtla_client:Using the following exogenous variables: Exogenous1, Exogenous2, day_0, day_1, day_2, day_3, day_4, day_5, day_6 INFO:nixtla.nixtla_client:Calling Forecast Endpoint... unique_iddsTimeGPT0BE2016-12-31 00:00:0074.5407731BE2016-12-31 01:00:0043.3442892BE2016-12-31 02:00:0044.4292203BE2016-12-31 03:00:0038.0943954BE2016-12-31 04:00:0037.389141 To learn more about how to use exogenous variables with TimeGPT, consult the Exogenous Variables tutorial. Important Considerations When using TimeGPT, the data cannot contain missing values. This means that for every series, there should be no gaps in the timestamps and no missing values in the target variable. For more, please refer to the tutorial on Dealing with Missing Values in TimeGPT. Minimum Data Requirements (for AzureAI) TimeGPT currently supports any amount of data for generating point forecasts. That is, the minimum size per series to expect results from this call nixtla_client.forecast(df=df, h=h, freq=freq) is one, regardless of the frequency. For Azure AI, when using the arguments level, finetune_steps, X_df (exogenous variables), or add_history, the API requires a minimum number of data points depending on the frequency. Here are the minimum sizes for each frequency: FrequencyMinimum SizeHourly and subhourly (e.g., “H”, “min”, “15T”)1008Daily (“D”)300Weekly (e.g., “W-MON”,…, “W-SUN”)64Monthly and other frequencies (e.g., “M”, “MS”, “Y”)48 For cross-validation, you need to consider these numbers as well as the forecast horizon (h), the number of windows (n_windows), and the gap between windows (step_size). Thus, the minimum number of observations per series in this case would be determined by the following relationship: Minimum number described previously + h + step_size + (n_windows - 1) Updated 3 months ago