Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
DLROLLINGS
Helper I
Helper I

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.dropna

df = df[Local Authority] != ''

df = df.[Local Authority] != '<NA>'

 

And others but keep getting errors or the values remain. 

 

Table below is an example of what I am trying to remove.

 

DLROLLINGS_0-1709888390229.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @DLROLLINGS 

 

@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] = None

 

Here is the result:

vnuocmsft_0-1710142556898.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @DLROLLINGS 

 

@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] = None

 

Here is the result:

vnuocmsft_0-1710142556898.png

 

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
Super User
Super 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,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors