> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nolano.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Formatting Input Data

> Learn about the required data format for time series forecasting with Nolano

## Data Format Requirements

### Time Series Structure

Your time series data must follow this JSON structure:

```json theme={null}
{
  "series": [
    {
      "timestamps": ["2023-01-01T00:00:00", "2023-01-02T00:00:00", "2023-01-03T00:00:00"],
      "values": [100, 102, 98]
    }
  ],
  "forecast_horizon": 7,
  "data_frequency": "Daily",
  "forecast_frequency": "Daily",
  "confidence": 0.95
}
```

### Timestamp Format

<AccordionGroup>
  <Accordion icon="calendar" title="ISO 8601 Format">
    All timestamps must be in ISO 8601 format: `YYYY-MM-DDTHH:MM:SS`

    **Examples:**

    * `2023-01-01T00:00:00` (Daily data)
    * `2023-01-01T10:30:00` (Hourly data)
    * `2023-01-01T10:30:45` (Minute-level data)

    <Note>
      Use consistent timezone formatting. We recommend UTC for global applications.
    </Note>
  </Accordion>

  <Accordion icon="clock" title="Supported Frequencies">
    The API supports these data frequencies:

    * **Seconds**: High-frequency data (e.g., stock prices, sensor readings)
    * **Minutes**: Sub-hourly data (e.g., website traffic, IoT metrics)
    * **Hours**: Hourly data (e.g., energy consumption, temperature)
    * **Daily**: Daily data (e.g., sales, website visits)
    * **Weekly**: Weekly aggregations (e.g., weekly revenue, user growth)
    * **Monthly**: Monthly data (e.g., monthly sales, subscription metrics)
    * **Quarterly**: Quarterly data (e.g., quarterly earnings, seasonal trends)
    * **Yearly**: Annual data (e.g., yearly revenue, long-term trends)
  </Accordion>
</AccordionGroup>

### Data Quality Requirements

<CardGroup cols={2}>
  <Card title="Minimum Data Points" icon="database">
    **Daily/Weekly**: At least 30 data points<br />
    **Monthly/Quarterly**: At least 12 data points<br />
    **Yearly**: At least 5 data points<br />
    **Hourly/Minutes/Seconds**: At least 100 data points
  </Card>

  <Card title="Data Completeness" icon="clock">
    No missing values in timestamps or values arrays<br />
    Arrays must have equal length<br />
    Values must be numeric (integers or floats)<br />
    Timestamps must be in chronological order
  </Card>
</CardGroup>

## Data Preparation Best Practices

### 1. Data Cleaning

<AccordionGroup>
  <Accordion icon="filter" title="Handle Missing Values">
    Before sending data to the API, ensure you've handled missing values:

    ```python theme={null}
    # Example: Forward fill missing values
    import pandas as pd

    df = pd.DataFrame({
        'timestamp': timestamps,
        'value': values
    })
    df = df.fillna(method='ffill')  # Forward fill
    # or
    df = df.interpolate()  # Linear interpolation
    ```
  </Accordion>

  <Accordion icon="filter" title="Outlier Detection">
    Consider removing or smoothing extreme outliers that could skew forecasts:

    ```python theme={null}
    # Example: Remove outliers using IQR method
    Q1 = df['value'].quantile(0.25)
    Q3 = df['value'].quantile(0.75)
    IQR = Q3 - Q1

    df_clean = df[
        (df['value'] >= Q1 - 1.5 * IQR) & 
        (df['value'] <= Q3 + 1.5 * IQR)
    ]
    ```
  </Accordion>
</AccordionGroup>

### 2. Seasonality Considerations

<CardGroup cols={2}>
  <Card title="Daily Seasonality" icon="sun">
    For daily data, consider day-of-week patterns. Include at least 4 weeks of data to capture weekly seasonality.
  </Card>

  <Card title="Monthly Seasonality" icon="calendar">
    For monthly data, include at least 2 years of data to capture annual seasonality patterns.
  </Card>
</CardGroup>

### 3. Data Granularity

<Note>
  **Choose the right frequency**: Use the highest frequency that makes sense for your use case. Higher frequency data can capture more patterns but requires more data points.
</Note>

## Setup Considerations

### API Configuration

<AccordionGroup>
  <Accordion icon="settings" title="Model Selection">
    Choose the appropriate model based on your data characteristics:

    * **forecast-model-1**: General purpose, good for most use cases
    * **forecast-model-2**: Better for complex seasonal patterns
    * **forecast-model-3**: Optimized for high-frequency data
    * **forecast-model-4**: Advanced deep learning for complex patterns
  </Accordion>

  <Accordion icon="target" title="Forecast Horizon">
    Set your forecast horizon based on your business needs:

    * **Short-term**: 1-7 periods for immediate planning
    * **Medium-term**: 8-30 periods for operational planning
    * **Long-term**: 30+ periods for strategic planning

    <Warning>
      Longer forecast horizons generally have higher uncertainty. Consider using confidence intervals for planning.
    </Warning>
  </Accordion>
</AccordionGroup>

## Common Data Patterns

### Example: E-commerce Sales Data

```json theme={null}
{
  "series": [
    {
      "timestamps": [
        "2023-01-01T00:00:00", "2023-01-02T00:00:00", "2023-01-03T00:00:00",
        "2023-01-04T00:00:00", "2023-01-05T00:00:00", "2023-01-06T00:00:00",
        "2023-01-07T00:00:00", "2023-01-08T00:00:00", "2023-01-09T00:00:00",
        "2023-01-10T00:00:00"
      ],
      "values": [1200, 1350, 1100, 1400, 1600, 1800, 2200, 1500, 1300, 1400]
    }
  ],
  "forecast_horizon": 14,
  "data_frequency": "Daily",
  "forecast_frequency": "Daily",
  "confidence": 0.95
}
```

### Example: Website Traffic (Hourly)

```json theme={null}
{
  "series": [
    {
      "timestamps": [
        "2023-01-01T00:00:00", "2023-01-01T01:00:00", "2023-01-01T02:00:00",
        "2023-01-01T03:00:00", "2023-01-01T04:00:00", "2023-01-01T05:00:00"
      ],
      "values": [150, 120, 80, 60, 50, 70]
    }
  ],
  "forecast_horizon": 24,
  "data_frequency": "Hours",
  "forecast_frequency": "Hours",
  "confidence": 0.90
}
```

## Troubleshooting

<AccordionGroup>
  <Accordion icon="alert-triangle" title="Common Errors">
    **"Invalid timestamp format"**: Ensure timestamps are in ISO 8601 format<br />
    **"Arrays must have equal length"**: Check that timestamps and values arrays have the same number of elements<br />
    **"Insufficient data points"**: Add more historical data points<br />
    **"Invalid frequency"**: Use one of the supported frequency values
  </Accordion>

  <Accordion icon="lightbulb" title="Performance Tips">
    * Use consistent time intervals when possible
    * Pre-process data to remove noise and outliers
    * Consider data seasonality when choosing forecast horizon
    * Test with smaller datasets before processing large volumes
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Make Your First Request" icon="play" href="/quickstart">
    Follow the quickstart guide to make your first forecast request with properly formatted data.
  </Card>

  <Card title="API Reference" icon="book" href="/api-reference/endpoint/forecast">
    Explore the complete API reference for detailed parameter documentation.
  </Card>
</CardGroup>
