Skip to content

Commit

Permalink
[MNT] address pd.DataFrame.groupby(axis=1) deprecatio in `EnsembleF…
Browse files Browse the repository at this point in the history
…orecaster` (#5707)

Fixes #5701

Changes accommodate deprecation of `pandas.DataFrame.groupby(axis=1)`
introduced in pandas 2.1.0.

References: 

-
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.groupby.html
and
https://github.com/pandas-dev/pandas/blob/d711b1d2ff9ee2c3faf0e118535d3d6218886a9d/pandas/core/frame.py#L9105-L9111
  • Loading branch information
ninedigits committed Jan 9, 2024
1 parent 1203bd5 commit 5ab2199
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sktime/forecasting/compose/_ensemble.py
Expand Up @@ -364,8 +364,14 @@ def _predict(self, fh, X):
"""
names, _ = self._check_forecasters()
y_pred = pd.concat(self._predict_forecasters(fh, X), axis=1, keys=names)
y_pred = y_pred.groupby(level=1, axis=1).agg(
_aggregate, self.aggfunc, self.weights
y_pred = (
y_pred.T.groupby(level=1)
.agg(
lambda y, aggfunc, weights: _aggregate(y.T, aggfunc, weights),
self.aggfunc,
self.weights,
)
.T
)
return y_pred

Expand Down

0 comments on commit 5ab2199

Please sign in to comment.