我写了这个函数来用 LabelEncoder 转换分类特征
#convert columns to dummies with LabelEncoder
cols = ['ToolType', 'TestType', 'BatteryType']
#apply ene hot encoder
le = LabelEncoder()
for col in cols:
data[col] = data[col].astype('|S') #convert object to str type before apply label encoder
le.fit(ravel(data[col]))
data[col] = le.transform(ravel(data[col]))
这些列中有空值,但是有这样的错误
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
有谁知道如何帮助我解决这个问题?谢谢