Hello,
The TimeSeriesImputer crashes when keep_trailing_nans = False, regardless of the method, if there are no trailing NANs in the TS.
I discovered the bug during the hands-on session of the tslearn workshop held at the end of March 2026 at Cyber Campus. Thank you again for the presentation and the lab.
Here is how to reproduce the code from the lab: https://github.com/ia-p16/tslearn-workshop-2026#.
# Imputer: this particular time series has missing data
# corresponding to the lla imu (feature 6 to 11)
dataset, tasks = get_X_y()
task = 1081
feature = 10
from tslearn.preprocessing import TimeSeriesImputer
imputed = TimeSeriesImputer(method="linear", keep_trailing_nans=False).fit_transform(dataset[task, :, feature].reshape(1, -1, 1))
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(12, 3))
fig.suptitle('Imputer')
plt.plot(dataset[task, :, feature], '-o')
plt.plot(imputed.reshape(-1), 'k:')
plt.ylabel("Value")
plt.xlabel("time index")
plt.show()
