我有包含整数和'NA'值的熊猫数据框列。Followinare 是列的唯一值 print(testData.LotFrontage.unique()) ['80' '81' '74' '78' '43' '75' 'NA' '63' '85' '70' '26' '21' '24']我需要用整数 0 替换这个字符串 NA。我尝试了以下代码NAReplace = {'NA': 0}trainingData.LotFrontage = [NAReplace[item] for item in trainingData.LotFrontage ]我收到一个错误 trainingData.LotFrontage = [NAReplace[item] for item in trainingData.LotFrontage ]KeyError: '65'这个问题的原因是什么?有没有其他方法可以做到这一点?
添加回答
举报
0/150
提交
取消