#11196·sktime

[BUG] 在不平衡面板上进行渲染会产生空值

作者: RobKuebler创建于 2026年9月18日更新于 2026年9月18日
标签bug

import pandas as pd import numpy as np from sktime.transformations.detrend import Detrender from sktime.forecasting.trend import TrendForecaster

A panel of 2 time series with DIFFERENT lengths (4 and 5),

as a pandas DataFrame with a 2-level MultiIndex (time index last),

which is the standard "pd-multiindex" sktime Panel mtype.

idx1 = pd.MultiIndex.from_product([[0], range(4)], names=["instance", "time"]) idx2 = pd.MultiIndex.from_product([[1], range(5)], names=["instance", "time"]) s1 = pd.Series([10.0, 20.0, 30.0, 40.0], index=idx1) # linear trend, slope 10 s2 = pd.Series([1.0, 2.0, 3.0, 4.0, 5.0], index=idx2) # linear trend, slope 1 panel = pd.concat([s1, s2]).to_frame(name="value") print(panel) t = Detrender(forecaster=TrendForecaster()) out = t.fit_transform(panel) print(out) print("input shape:", panel.shape) print("output shape:", out.shape) print("any NaN:", out.isna().any().any()) Output: value instance time
0 0 10.0 1 20.0 2 30.0 3 40.0 1 0 1.0 1 2.0 2 3.0 3 4.0 4 5.0 value instance time
0 0 0.0 1 0.0 2 0.0 3 0.0 4