from sklearn.compose import ColumnTransformer ct = ColumnTransformer([('encoder', OneHotEncoder(), [1])], remainder='passthrough') X = np.array(ct.fit_transform(X), dtype=np.float)