0

I am trying to do label encoding using sci kit learn's built in function but why does my result print as row instead of an additional column?

from sklearn.preprocessing import LabelEncoder

# creating instance of labelencoder
labelencoder = LabelEncoder()
# Assigning numerical values and storing in another column
y_data['coded_sklearn'] = labelencoder.fit_transform(y_data['coded_sklearn'])

print(y_data)

enter image description here

odebear
  • 69
  • 1
  • 8
  • Did you create a `Data-Frame` before doing this step @odebear? – YScharf Feb 20 '22 at 14:05
  • @YScharf I loaded in a csv file and used below codes to get the y_data ``` y_col_name = 'Class' y_data = data[y_col_name] ``` – odebear Feb 20 '22 at 14:24
  • Did you mean to write `y_data['coded_sklearn'] = labelencoder.fit_transform(y_data['numeric'])` ? With `numeric` representing the `column name` of the label-data in the `Data-Frame`? – YScharf Feb 20 '22 at 15:00

0 Answers0