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:
# 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, train.shape) train_scaled = scaler.transform(train) # transform test test = test.reshape(test.shape, test.shape) 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)
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.