I'm new to python and pandas. I have a dataframe that looks as follows:
ID NAME
0 0000001 Apple
1 0000002 35
2 0000003 Grape
3 0000004 22
4 0000005 Banana
5 0000006 12
My goal is to replace the fields with numbers in the NAME column with 'Unknown'
So far, I have tried the following:
out['NAME'] = out.apply(lambda x: x['NAME'].replace(x['NAME'], 'Unknown'))
But it wouldn't seem to replace it and gives me a KeyError: ('NAME', 'occurred at index ID')
Ultimately I am expecting an output as follows:
ID NAME
0 0000001 Apple
1 0000002 Unkown
2 0000003 Grape
3 0000004 Unkown
4 0000005 Banana
5 0000006 Unkown
question from:
https://stackoverflow.com/questions/65909227/identify-integers-in-column-and-replace-with-string 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…