I have dataset that includes categorial column for education level the initial values was 0,nan, high school, graduate school, university I have cleaned the data and convert it to the following values
0-> others 1-> high school 2-> graduate school 3-> university
in the same column, now I want to hot encode this column to 4 columns
I have tried to use scikit learn as following
onehot_encoder = OneHotEncoder() onehot_encoded = onehot_encoder.fit_transform(df_csv['EDUCATION']) print(onehot_encoded)
and I got this error
ValueError: Expected 2D array, got 1D array instead: array=[3 3 3 ... 3 1 3]. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.