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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register 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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors