# Getting started with function-backed time series This guide will help you get started with creating a function-backed time series that can be used in Quiver analyses to enable real-time forecasting workflows. ## Prerequisites To set up function-backed time series, you need the following resources: * A Foundry function that returns a numeric time series using the time series SDK. * A tagged version of that function to reference in Quiver. ## Set up a function-backed time series in Quiver 1. **Install the time series SDK:** In Code Repositories, add the `timeseries-sdk` library to your code repository using the **Libraries** tab.

![The time series SDK package installed in a code repository.](../../../assets/bdd8b725ff13d2037e58da201e3f5237b8a0a9fcec78910fac173f44fd2b91e0.webp)

2. **Write a Python function:** Create a function that returns a serialized pandas DataFrame with the following columns: * **`timestamp`:** A pandas timestamp. * **`value`:** A numeric value, for example int32 or float. The time series SDK provides a library for serializing a pandas DataFrame as shown in the example below. ```python from functions.api import function from timeseries_sdk.types import TimeSeries from ontology_sdk.ontology.objects import Machine import pandas as pd @function def performance_prophet_forecast( machine: Machine, periods: int = 96, # number of future steps freq: str = "15min", # sampling frequency ) -> list[bytes]: """ Forecast a machine's performance_score using Prophet. """ from prophet import Prophet # Retrieve performance score data (columns: timestamp, value) df = machine.performance_score.to_pandas(all_time=True) if df.empty: return TimeSeries.serialize(pd.DataFrame(columns=["timestamp", "value"])) # Prepare the data for Prophet df = df.rename(columns={"timestamp": "ds", "value": "y"}).sort_values("ds") model = Prophet().fit(df) # Create future data frame for forecast future = model.make_future_dataframe(periods=periods, freq=freq, include_history=True) forecast = model.predict(future) # Format the forecast output out = forecast[["ds", "yhat"]].rename(columns={"ds": "timestamp", "yhat": "value"}) return TimeSeries.serialize(out) ``` 3. **Publish the function:** Publish your function and tag a version. 4. **Use the function in Quiver:** * Add a **Code function time series card**.

![The Quiver card selection panel showing the Function time series option.](../../../assets/e9282c1a22c4417940821976251123130e5883a3c4c34ae605b316c0efdbe1e7.webp)

* Select your function, choose the correct version, and configure its inputs.

![The Quiver card configuration panel showing function selection and input settings.](../../../assets/1f2622f9d9b9e097e11ae2e97806754a5c1ef9079618d4d0154c68ac0e0583f6.webp)

* Optionally, add another instance of the card to compare multiple scenarios side-by-side. ![A preview of the function-backed time series visualization in Quiver.](../../../assets/cb9d927d0158611ba801a4afa28b3dd6ee8f7a034d59cd27006b4b2a3b29e779.webp)