Skip to content

Commit

Permalink
[MNT] pandas 2.2.X compatibility fixes (#5840)
Browse files Browse the repository at this point in the history
Adds fixes for `pandas 2.2.X` compatibility:

* ensures index sorting in `update_predict` - previously, this was
automatic, but now has to be enforced due to behaviour change of
`pd.concat`.
  • Loading branch information
fkiraly committed Feb 22, 2024
1 parent 903c667 commit 3d26495
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sktime/forecasting/base/_base.py
Expand Up @@ -2511,4 +2511,9 @@ def _format_moving_cutoff_predictions(y_preds, cutoffs):
cutoffs = [cutoff[0] for cutoff in cutoffs]
y_pred = pd.concat(y_preds, axis=1, keys=cutoffs)

if not y_pred.index.is_monotonic_increasing:
y_pred = y_pred.sort_index()
if hasattr(y_pred, "columns") and not y_pred.columns.is_monotonic_increasing:
y_pred = y_pred.sort_index(axis=1)

return y_pred

0 comments on commit 3d26495

Please sign in to comment.