This code returns the expected results. But there are 2 pandas methods involved. Can I use only 1 method or remove pandas from fit_transform?
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
data = [-1, 2,1, 18]
scaler.fit_transform(pd.DataFrame(pd.Series(data)))
array([[0. ],
[0.15789474],
[0.10526316],
[1. ]])
Update: I tried feeding the list, but got an error:
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
data = [-1, 2,1, 18]
scaler.fit_transform(data)
# ValueError: Expected 2D array, got 1D array instead
This works, but getting wrong results:
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
data = [-1, 2,1, 18]
scaler.fit_transform([data])
# array([[0., 0., 0., 0.]])