Skip to content

Add TimeSeries.has_nan property to check for NaN values - #3195

Open
webzuweb wants to merge 1 commit into
unit8co:masterfrom
webzuweb:feat/has-nan-property
Open

Add TimeSeries.has_nan property to check for NaN values#3195
webzuweb wants to merge 1 commit into
unit8co:masterfrom
webzuweb:feat/has-nan-property

Conversation

@webzuweb

Copy link
Copy Markdown

Partial contribution towards #1278.

Summary

Adds a has_nan property to TimeSeries that indicates whether the series contains any NaN values. This was explicitly suggested in #1278 ("Might be also useful to create a TimeSeries property which indicates if there are some nan in the time series") and is useful for users deciding whether a series can be passed to models/historical forecasts that don't handle NaNs.

Changes

  • darts/timeseries.py: new has_nan property (np.isnan(self._values).any()), placed alongside the other has_* properties.
  • darts/tests/test_timeseries.py: new test_has_nan covering univariate with NaN, clean univariate, integer series, and multivariate with NaN.

Verification

pytest darts/tests/test_timeseries.py::TestTimeSeries::test_has_nan  # 1 passed

@webzuweb
webzuweb requested a review from dennisbader as a code owner August 30, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant