It is the first time I am using ColumnTransformer and I face an issue with the dimension of the array.
Here is my dataframe called 'concat_data' :
Date Hour Observation
0 01/09/2015 0 10
1 01/09/2015 1 9
2 01/09/2015 2 8
3 01/09/2015 3 10
4 01/09/2015 4 12
I am trying to apply a standard scaler only on the Observation column with the following code :
preprocessor = ColumnTransformer(
transformers=[
('num', StandardScaler(), ['Observation'])],
remainder="passthrough")
preprocessor.fit(concat_data, concat_data['Observation'])
I get this error message :
ValueError: 1D data passed to a transformer that expects 2D data. Try to specify the column selection as a list of one item instead of a scalar.
I could do it without ColumnTransformer but my objective is to understand how ColumnTransformer works. For instance, this code works :
StandardScaler().fit(concat_data[['Observation']])
Thanks all !