在Scikit中跨多个列进行标签编码-学习
LabelEncoder
DataFrame
LabelEncoder
LabelEncoder
DataFrame
LabelEncoder
import pandasfrom sklearn import preprocessing df = pandas.DataFrame({ 'pets': ['cat', 'dog', 'cat', 'monkey', 'dog', 'dog'], 'owner': ['Champ', 'Ron', 'Brick', 'Champ', 'Veronica', 'Ron'], 'location': ['San_Diego', 'New_York', 'New_York', 'San_Diego', 'San_Diego', 'New_York']})le = preprocessing.LabelEncoder()le.fit(df)
追溯(最近一次调用):文件“,第1行,在文件”/Users/bbalin/anaconda/lib/python2.7/site-packages/sklearn/preprocessing/label.py“,第103行,在FIT y=列_或_1D(y,WARN=True)文件”/Users/bbalin/anaconda/lib/python2.7/site-packages/sklearn/utils/validation.py“,行306中,在列_或_1D中提高ValueError(”坏输入形状{0}“。格式(形状)值错误:输入形状错误(6,3)
相关分类