I have pandas dataframe column which has integers and 'NA' values. Followinareis the unique values of the column
print(testData.LotFrontage.unique())
['80' '81' '74' '78' '43' '75' 'NA' '63' '85' '70' '26' '21' '24']
I need to replace this string NA with integer 0. I tried following code
NAReplace = {'NA': 0}
trainingData.LotFrontage = [NAReplace[item] for item in trainingData.LotFrontage ]
and I am getting an error
trainingData.LotFrontage = [NAReplace[item] for item in trainingData.LotFrontage ]
KeyError: '65'
What is the reason for this issue? Is there any other way to do this?