Prophet fails with OutOfBoundsDatetime on dates outside `datetime64[ns]` range

Open
#2,689 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #2690 by @NikhithReddyScripts — closed without merging

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
pandas, python
Domain
data

Research direction

Start in forecaster.py at line 1136 and run the issue's minimal reproduction with the listed Prophet, pandas, and Python versions. Determine whether the supported outcome is graceful handling or a clear date-range error, then verify that dates outside the datetime64[ns] range no longer produce an uninformative OutOfBoundsDatetime crash.

Written by the indexing model from the issue text.

Description

Summary

Prophet crashes when processing dates outside the datetime64[ns] range, even though these dates could be valid with lower precision datetime types.

Expected Behavior

Prophet should either:

  1. Handle dates gracefully by using appropriate precision, or
  2. Provide a clear error message about supported date ranges
Actual Behavior

Prophet crashes with OutOfBoundsDatetime exception.

Minimal Reproduction
from prophet import Prophet
import pandas as pd

# Prophet crashes on dates outside datetime64[ns] range
df = pd.DataFrame({
    'ds': ['3969-12-02', '3969-12-03'],
    'y': [1.0, 2.0]
})

model = Prophet()
model.fit(df)  # Fails with OutOfBoundsDatetime
Error Output

pandas._libs.tslibs.np_datetime.OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 3969-12-02, at position 0

Root Cause

The issue occurs in forecaster.py:1136:
self.history_dates = pd.to_datetime(pd.Series(df['ds'].unique(), name='ds')).sort_values()

Prophet internally converts all datetime inputs to datetime64[ns] regardless of the input format or required precision. This hardcoded conversion fails for dates outside the nanosecond timestamp range.

Environment
  • Prophet version: 1.1.7
  • Pandas version: 2.3.1
  • Python version: 3.12.9
Dominant language
Python
Stars
20.5k
Forks
4.6k
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from facebook/prophet

All issues in facebook/prophet

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.