Skip to content

Commit

Permalink
warn user if suspicion of wrong index in from_group_dataframe() (#1628)
Browse files Browse the repository at this point in the history
* warn user if suspicion of wrong index in TimeSeries.from_group_dataframe()

* imroved warning message

---------

Co-authored-by: madtoinou <32447896+madtoinou@users.noreply.github.com>
  • Loading branch information
dennisbader and madtoinou authored Mar 11, 2023
1 parent fdc5a31 commit 301122e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions darts/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,9 +745,10 @@ def from_group_dataframe(
timestamps) or a RangeIndex (if it contains integers).
If not set, the DataFrame index will be used. In this case the DataFrame must contain an index that is
either a pandas DatetimeIndex, a pandas RangeIndex, or a pandas Index that can be converted to a
RangeIndex. It is better if the index has no holes; alternatively setting `fill_missing_dates` can in some
cases solve these issues (filling holes with NaN, or with the provided `fillna_value` numeric value, if
any).
RangeIndex. Be aware that the index must represents the actual index of each individual time series group
(can contain non-unique values). It is better if the index has no holes; alternatively setting
`fill_missing_dates` can in some cases solve these issues (filling holes with NaN, or with the provided
`fillna_value` numeric value, if any).
value_cols
A string or list of strings representing the value column(s) to be extracted from the DataFrame. If set to
`None`, the whole DataFrame will be used.
Expand Down Expand Up @@ -775,6 +776,13 @@ def from_group_dataframe(
List[TimeSeries]
A list containing a univariate or multivariate deterministic TimeSeries per group in the DataFrame.
"""
if time_col is None and df.index.is_monotonic_increasing:
logger.warning(
"UserWarning: `time_col` was not set and `df` has a monotonically increasing (time) index. This "
"results in time series groups with non-overlapping (time) index. You can ignore this warning if the "
"index represents the actual index of each individual time series group."
)

group_cols = [group_cols] if not isinstance(group_cols, list) else group_cols
if static_cols is not None:
static_cols = (
Expand Down

0 comments on commit 301122e

Please sign in to comment.