I am trying to use OneHotEncoding to transform the second column of my csv file, which consists of company names.
from sklearn.preprocessing import OneHotEncoder
ct = ColumnTransformer(transformers=[('encoder', OneHotEncoder(), [1])]), remainder='passthrough'
X = np.array(ct.fit_transform(X))
and I received this error:
ct = ColumnTransformer(transformers=[('encoder', OneHotEncoder(), [1])]), remainder='passthrough'
^
SyntaxError: can't assign to function call
Where did i go wrong? I understand that perhaps there is an error with how I wrote the ct line, but i do not know exactly what I did wrong.
I think you set a bracket incorrectly and it should probably be like this:
ct = ColumnTransformer(transformers=[('encoder', OneHotEncoder(), [1])], remainder='passthrough')