Skip to content

pandas 3.0 incompatibility: multiple groupby('ID') failures + .view(dtype=) removed #1707

Description

@Jeroenpas

Summary

NeuralProphet rc10 (and current main) has multiple incompatibilities with pandas 3.0 (released early 2026). After upgrading pandas to 3.0, every m.fit() and m.predict() call fails with cascading errors. We have identified at least 5 distinct failure points across 3 modules.

Environment

  • NeuralProphet: 1.0.0rc10 (also tested with current main branch — same code paths)
  • pandas: 3.0.2
  • pytorch-lightning: 2.6.x
  • Python: 3.14.4

Failures (in order of discovery)

1. df_utils.get_freq_dist.view(dtype=) removed

File "neuralprophet/df_utils.py", line 1120, in get_freq_dist
    converted_ds = pd.to_datetime(ds_col, utc=True).view(dtype=np.int64)
AttributeError: 'Series' object has no attribute 'view'

Series.view(dtype=...) was deprecated in pandas 2.x and removed in 3.0.

Fix proposal: replace with .astype('int64') — equivalent semantically (nanoseconds since epoch) and works in pandas 1.x/2.x/3.0.

2. data.process._handle_missing_data.drop(columns=["ID"]) fails

File "neuralprophet/data/process.py", line 485
    df_grouped = df.groupby("ID").apply(...).drop(columns=["ID"])
KeyError: "['ID'] not found in axis"

In pandas 3.0, groupby('ID').apply(...) no longer includes the group key as a column in the result DataFrame — it's only in the MultiIndex. .drop(columns=['ID']) then fails.

Fix proposal: add errors="ignore" or use apply(..., include_groups=False).

3. data.transform._normalizedf.groupby("ID") on df without ID column

File "neuralprophet/data/transform.py", line 28, in _normalize
    for df_name, df_i in df.groupby("ID"):
KeyError: 'ID'

After our workarounds for issues 1+2, m.predict() calls _normalize on a DataFrame that has no 'ID' column. In pandas 3.0, this raises KeyError; in pandas 2.x it likely auto-injected.

Reproducer (after applying patches for #1 and #2):

import pandas as pd
from neuralprophet import NeuralProphet

df = pd.DataFrame({
    "ds": pd.date_range("2024-01-01", periods=200, freq="D"),
    "y": range(200),
})
df["ID"] = "default"  # explicit single-series ID
m = NeuralProphet(n_lags=14, n_forecasts=1)
m.fit(df, freq="D")
future = m.make_future_dataframe(df, periods=30)
future["ID"] = "default"
forecast = m.predict(future)  # Fails here even with explicit ID

Even with explicit ID="default" set on both df and future, internal transformations within m.predict() strip the ID column before reaching _normalize. We have not been able to determine which internal call removes it.

4. Implicit dependency: tensorboard / tensorboardX

PyTorch Lightning 2.x's MetricsLogger requires tensorboard or tensorboardX for logging. Not declared as explicit dep in NeuralProphet.

Fix proposal: add tensorboardX to pyproject.toml as runtime dep (or document it).

Impact

We have NeuralProphet completely disabled in our production system since 2026-04-25 (pandas upgrade). Affects ~60 daily forecast runs across our portfolio.

Workarounds we tried (all incomplete)

We have a working monkey-patch module (api/_nprophet_compat.py) that handles issues #1 and #2 + tries to handle ID-column injection. However we cannot fix issue #3 from outside the library because m.predict() strips the ID column internally between our injection point and _normalize.

Request

Could the maintainers either:

  1. Pin pandas<3.0 in pyproject.toml until fixes land, OR
  2. Apply the suggested fixes above (we can submit a PR if helpful)

We would prefer option 2 — happy to contribute the patches we developed.

Thanks for an excellent library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions