我正在尝试使用 map 函数更改数据中的字符串做数值。
这是数据:
label sms_message
0 ham Go until jurong point, crazy.. Available only ...
1 ham Ok lar... Joking wif u oni...
2 spam Free entry in 2 a wkly comp to win FA Cup fina...
3 ham U dun say so early hor... U c already then say...
4 ham Nah I don't think he goes to usf, he lives aro...
我正在尝试使用以下方法将“垃圾邮件”更改为 1,将“火腿”更改为 0:
df['label'] = df.label.map({'ham':0, 'spam':1})
但结果是:
label sms_message
0 NaN Go until jurong point, crazy.. Available only ...
1 NaN Ok lar... Joking wif u oni...
2 NaN Free entry in 2 a wkly comp to win FA Cup fina...
3 NaN U dun say so early hor... U c already then say...
4 NaN Nah I don't think he goes to usf, he lives aro...
任何人都可以识别问题吗?
开心每一天1111
相关分类