I am encoding two columns with index numbers 1 and 2 that is column number 2 and 3, using the following code, however, I am facing an error of invalid syntax : If I am using only 1 in the index value it is ok, please help on this.. how can I encode two columns simultaneously using OneHotEncoder here.
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OneHotEncoder
ct = ColumnTransformer(transformers = [('encoder', OneHotEncoder(),[1:2])], remainder ='passthrough')
X = np.array(ct.fit_transform(X))
If I am using the following it is ok but I want to encode the other column as well.
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OneHotEncoder
ct = ColumnTransformer(transformers = [('encoder', OneHotEncoder(),[1])], remainder ='passthrough')
X = np.array(ct.fit_transform(X))