【发布时间】:2020-12-16 17:13:57
【问题描述】:
我有一个相当大的数据框,其中包含数值和分类值。我正在尝试对分类值进行编码,但出现上述错误。
这是一个简单版本的代码:
from collections import defaultdict
d = defaultdict(LabelEncoder)
# Encoding the variable
fit = df[catgoricalValues].apply(lambda x: d[x.name].fit_transform(df[catgoricalValues]))
我正在使用here 描述的方法,但我没有将其应用于整个数据帧,而是指定了要编码的列。
我收到此错误:
ValueError: bad input shape (490546, 11)
【问题讨论】:
标签: python pandas scikit-learn