Time series normalization using min max technique I have a time series dataset and I would like to normalize the data (diff which is of type list) as below using Min Max technique. But, I get the following error:

Code:

# split data into train and test-sets
train, test = diff[0:1486], diff[1486:2123]
from sklearn.preprocessing import MinMaxScaler
# scale train and test data to [-1, 1]
def scale(train, test):
    # fit scaler
    scaler = MinMaxScaler(feature_range=(-1, 1))
    scaler = scaler.fit(train)
    # transform train
    train = train.reshape(train.shape[0], train.shape[1])
    train_scaled = scaler.transform(train)
    # transform test
    test = test.reshape(test.shape[0], test.shape[1])
    test_scaled = scaler.transform(test)
    return scaler, train_scaled, test_scaled
# transform the scale of the data
scaler, train_scaled, test_scaled = scale(train, test)


Error:

ValueError: Input contains NaN, infinity or a value too large for dtype('float64').
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
To resolve the issue, I used diff() method to remove trends in diff.diff()