Python 在Jupyter笔记本中使用标签编码器编码数据帧时获取错误消息

Python 在Jupyter笔记本中使用标签编码器编码数据帧时获取错误消息,python,pandas,encoder,Python,Pandas,Encoder,代码段显示以下错误消息 CODE l1=LabelEncoder() df_con_enc=df_con.apply(l1.fit_transform) 错误消息 --------------------------------------------------------------------------- TypeError回溯(最近一次调用上次) 编码中的~\anaconda3\lib\site packages\sklearn\preprocessing\\u label.py(

代码段显示以下错误消息

CODE
l1=LabelEncoder()
df_con_enc=df_con.apply(l1.fit_transform)

错误消息
---------------------------------------------------------------------------
TypeError回溯(最近一次调用上次)
编码中的~\anaconda3\lib\site packages\sklearn\preprocessing\\u label.py(值、唯一性、编码、检查未知)
112尝试:
-->113 res=_encode_python(值、唯一性、编码)
114除类型错误外:
python中的~\anaconda3\lib\site packages\sklearn\preprocessing\\u label.py(值、唯一性、编码)
60如果uniques为无:
--->61唯一性=已排序(设置(值))
62 uniques=np.array(uniques,dtype=values.dtype)
TypeError:'
ERROR MESSAGE
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~\anaconda3\lib\site-packages\sklearn\preprocessing\_label.py in _encode(values, uniques, encode, check_unknown)
    112         try:
--> 113             res = _encode_python(values, uniques, encode)
    114         except TypeError:

~\anaconda3\lib\site-packages\sklearn\preprocessing\_label.py in _encode_python(values, uniques, encode)
     60     if uniques is None:
---> 61         uniques = sorted(set(values))
     62         uniques = np.array(uniques, dtype=values.dtype)

TypeError: '<' not supported between instances of 'str' and 'float'

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-236-2a15c97ba0b0> in <module>
----> 1 df_con_enc=df_con.apply(l1.fit_transform)

~\anaconda3\lib\site-packages\pandas\core\frame.py in apply(self, func, axis, raw, result_type, args, **kwds)
   6876             kwds=kwds,
   6877         )
-> 6878         return op.get_result()
   6879 
   6880     def applymap(self, func) -> "DataFrame":

~\anaconda3\lib\site-packages\pandas\core\apply.py in get_result(self)
    184             return self.apply_raw()
    185 
--> 186         return self.apply_standard()
    187 
    188     def apply_empty_result(self):

~\anaconda3\lib\site-packages\pandas\core\apply.py in apply_standard(self)
    311 
    312         # compute the result using the series generator
--> 313         results, res_index = self.apply_series_generator()
    314 
    315         # wrap results

~\anaconda3\lib\site-packages\pandas\core\apply.py in apply_series_generator(self)
    339         else:
    340             for i, v in enumerate(series_gen):
--> 341                 results[i] = self.f(v)
    342                 keys.append(v.name)
    343 

~\anaconda3\lib\site-packages\sklearn\preprocessing\_label.py in fit_transform(self, y)
    254         """
    255         y = column_or_1d(y, warn=True)
--> 256         self.classes_, y = _encode(y, encode=True)
    257         return y
    258 

~\anaconda3\lib\site-packages\sklearn\preprocessing\_label.py in _encode(values, uniques, encode, check_unknown)
    115             types = sorted(t.__qualname__
    116                            for t in set(type(v) for v in values))
--> 117             raise TypeError("Encoders require their input to be uniformly "
    118                             f"strings or numbers. Got {types}")
    119         return res

TypeError: Encoders require their input to be uniformly strings or numbers. Got ['float', 'str']