Forum Discussion
Anonymous
2 years agoNot applicable
Removed <NA> from dataframe
Hi all I am new to python and I am looking at the regression modelling, I am trying to find out how I can remove the <NA> from the Local Authority column in python. I have tried df = df....
- Anonymous2 years ago
Hi Anonymous
ibarrau Thanks for your sharing!
After testing, I offer an alternative approach:
local_authority_index = 1 #The number here is determined by the column where your <NA> is located. for row in df[1:]: row[localauthority_index] = NoneHere is the result:
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ibarrau
2 years agoSuper User
Hi. That <NA> doesn't look like a traditional nan that can be droped with the functions, it just looks like regular text. Have you tried to replace it? Somethig like replacing that for real none value:
df['Local Authority'] = df['Local Authority'].replace('<NA>', None)
I haven't tested but I think that might work. If you have more <NA> in other columns you can write the same code without the columns at df.
I hope that helps,