Shape mismatch: if categories is an array, it has to be of shape (n_features,)
问题 Here is the code I'm trying to execute to encode the values of the first column of my data set using dummy values. import numpy as py import matplotlib.pyplot as plt import pandas as pd DataSet = pd.read_csv('Data.csv') x=DataSet.iloc[:, :-1].values y=DataSet.iloc[:,3].values from sklearn.impute import SimpleImputer imputer=SimpleImputer(missing_values=py.nan,strategy='mean') imputer=imputer.fit(x[:, 1:3]) x[:, 1:3]=imputer.transform(x[:, 1:3]) from sklearn.preprocessing import OneHotEncoder