# Time series forecasting with code

> Time series forecasting with code - Learn about DataRobot time series forecasting using a car sales
> dataset and a Jupyter notebook.

This Markdown file sits beside the HTML page at the same path (with a `.md` suffix). It summarizes the topic and lists links for tools and LLM context.

Companion generated at `2026-05-06T18:17:09.951834+00:00` (UTC).

## Primary page

- [Time series forecasting with code](https://docs.datarobot.com/en/docs/get-started/how-to/ts-car-sales-nb.html): Full documentation for this topic (HTML).

## Sections on this page

- [1: Upload the notebook](https://docs.datarobot.com/en/docs/get-started/how-to/ts-car-sales-nb.html#1upload-the-notebook): In-page section heading.
- [2: Configure the notebook environment](https://docs.datarobot.com/en/docs/get-started/how-to/ts-car-sales-nb.html#2configure-the-notebook-environment): In-page section heading.
- [3: Run the environment](https://docs.datarobot.com/en/docs/get-started/how-to/ts-car-sales-nb.html#3run-the-environment): In-page section heading.
- [4: Import libraries and data](https://docs.datarobot.com/en/docs/get-started/how-to/ts-car-sales-nb.html#4import-libraries-and-data): In-page section heading.
- [5: Configure the time series experiment](https://docs.datarobot.com/en/docs/get-started/how-to/ts-car-sales-nb.html#5configure-the-time-series-experiment): In-page section heading.
- [6: Run the experiment](https://docs.datarobot.com/en/docs/get-started/how-to/ts-car-sales-nb.html#6run-the-experiment): In-page section heading.
- [7: Create experiments for each segment](https://docs.datarobot.com/en/docs/get-started/how-to/ts-car-sales-nb.html#7create-experiments-for-each-segment): In-page section heading.
- [Next steps](https://docs.datarobot.com/en/docs/get-started/how-to/ts-car-sales-nb.html#next-steps): In-page section heading.

## Related documentation

- [Get started](https://docs.datarobot.com/en/docs/get-started/index.html): Linked from this page.
- [How-tos](https://docs.datarobot.com/en/docs/get-started/how-to/index.html): Linked from this page.
- [a continuation of part 1](https://docs.datarobot.com/en/docs/get-started/how-to/time-series-walk.html): Linked from this page.
- [Developer quickstart](https://docs.datarobot.com/en/docs/api/dev-learning/api-quickstart.html): Linked from this page.
- [DataRobot-hosted notebooks](https://docs.datarobot.com/en/docs/workbench/wb-notebook/index.html): Linked from this page.
- [Codespaces](https://docs.datarobot.com/en/docs/workbench/wb-notebook/codespaces/index.html): Linked from this page.
- [Notebook environment management](https://docs.datarobot.com/en/docs/workbench/wb-notebook/wb-code-nb/wb-env-nb.html): Linked from this page.
- [Create and execute cells documentation](https://docs.datarobot.com/en/docs/workbench/wb-notebook/wb-code-nb/wb-cell-nb.html): Linked from this page.
- [Time series framework](https://docs.datarobot.com/en/docs/reference/pred-ai-ref/ts-reference/ts-framework.html): Linked from this page.
- [Multiseries modeling](https://docs.datarobot.com/en/docs/classic-ui/modeling/time/multiseries.html): Linked from this page.
- [Enable time-aware modeling](https://docs.datarobot.com/en/docs/workbench/nxt-workbench/experiments/create-experiments/create-time-aware/ts-forecasting.html#enable-time-aware-modeling): Linked from this page.
- [Set backtest partitions](https://docs.datarobot.com/en/docs/workbench/nxt-workbench/experiments/create-experiments/create-time-aware/ts-datetime.html#3-set-backtest-partitions): Linked from this page.
- [Time series modeling data](https://docs.datarobot.com/en/docs/classic-ui/modeling/time/ts-modeling-data/ts-create-data.html): Linked from this page.
- [model factory code example](https://docs.datarobot.com/en/docs/api/dev-learning/accelerators/model-building-tuning/python-multi.html): Linked from this page.
- [Leverage AI Accelerators](https://docs.datarobot.com/en/docs/api/dev-learning/accelerators/index.html): Linked from this page.

## Documentation content

This walkthrough, [a continuation of part 1](https://docs.datarobot.com/en/docs/get-started/how-to/time-series-walk.html), showcases a car sales forecasting example to learn about DataRobot time series. Watch the full video of this use case on [YouTube](https://www.youtube.com/watch?v=Qh_sQ1OrT2A).

The dataset includes month-by-month sales for many makes and models of vehicles. You will create an experiment and build models in the UI and then import a Jupyter-formatted notebook to view more detailed segment analysis using DataRobot insights.

Before proceeding with the workflow, review the [Developer quickstart](https://docs.datarobot.com/en/docs/api/dev-learning/api-quickstart.html) to get familiar with common API tasks and configuration.

**Assets for download**

Download the following car sales-related assets—a shorter version of the data ( `FAST`), a fuller version with more segments ( `_Segments`) and  a Python notebook ( `_Model_Factory.ipynb`):

[Download assets](https://datarobot-doc-assets.s3.us-east-1.amazonaws.com/DataRobot%2BTime%2BSeries%2BCar%2BSales%2BForecasting.zip)

### 1: Upload the notebook

From the Notebooks tab of the Use Case folder, select Upload Notebook and navigate to the notebook file that provided with this walkthrough. Then click Import.

Once uploaded, the accelerator will open in DataRobot Notebooks as part of the Use Case.

Read more:

- DataRobot-hosted notebooks
- Codespaces

### 2: Configure the notebook environment

To edit, create, or run the code in the accelerator, you must first configure and then run the notebook environment. The environment image determines the coding language, dependencies, and open-source libraries used in the notebook. To see the list of all packages available in the image, hover over it in the Environment tab:

Review the available environments, and, for this walkthrough, select the Python 3.9.18 image and select the default environment settings.

Read more: [Notebook environment management](https://docs.datarobot.com/en/docs/workbench/wb-notebook/wb-code-nb/wb-env-nb.html)

### 3: Run the environment

To begin working with the accelerator, start the environment by toggling it on in the toolbar.

Wait a moment for the environment to initialize, and once it displays the Started status, you can begin executing code.  To execute code, select the play button next to a cell.

Read more: [Create and execute cells documentation](https://docs.datarobot.com/en/docs/workbench/wb-notebook/wb-code-nb/wb-cell-nb.html)

### 4: Import libraries and data

With the environment running, run the cells to import the required libraries, connect to DataRobot, and import the dataset. This walkthrough uses the fast version of the dataset, containing fewer vehicles and segments. To use a dataset with all vehicles, uncomment and use the alternative dataset path provided in the cell instead.

After importing the data, reviewing the contents of the Pandas Dataframe. The proceeding cell selects five of the ten vehicle segments at random and plots them to display the shape of the data.

### 5: Configure the time series experiment

Run the cell that defines the experiment settings (matching the configuration done in the DataRobot UI). This cell creates a time series experiment using all of the vehicles in the data frame. DataRobot will create an experiment for each vehicle segment. Reference some information about the features below:

- The target is Sales_Volume .
- The date feature is date .
- The known in advance features are Brand and Major_Segment .
- The multiseries column ID is Model .
- The feature derivation window is from -13 to -1 .
- The forecast window is from 2 to 4 months in the future.

Read more:

- Time series framework
- Multiseries modeling
- Enable time-aware modeling
- Set backtest partitions
- Time series modeling data

### 6: Run the experiment

Next, create an experiment using all of the data in the Pandas Dataframe. This cell initiates DataRobot Autopilot for modeling. Allow some time for Autopilot to complete and build the experiment. You can reference the DataRobot GUI to monitor Autopilot's progress.

### 7: Create experiments for each segment

The proceeding cells creates and an experiment for each unique value of `Major_Segment` in the Dataframe. In this walkthrough, you will create an experiment for the `Car` and `Pickup` segments. To do so, first subset the data by the segment. Then you will assign a name for each experiment created based on the vehicle segment. These experiments will leverage the time series settings specified in previous steps. Then, you will run Autopilot again for these experiments. This cell includes a print statement to inform you of which experiment DataRobot is currently building.

### Next steps

When Autopilot completes, you will have a set of experiments for the major segments. This walkthrough demonstrates DataRobot's ability to automate experimentation using Python loops to accomplish exploratory work quickly. In addition to looping by segment, you can loop for individual models, individual forecast distance, or for different feature derivation windows. Reference the [model factory code example](https://docs.datarobot.com/en/docs/api/dev-learning/accelerators/model-building-tuning/python-multi.html) for more information.

From here, you can also:

- Create DataRobot Notebooks .
- Leverage AI Accelerators .
