1

I am using Python 3.7.6 .I am working on Bank Marketing project. The CSV file have "age" column, that has some null values in it. So I want to drop those age values with NaN. I was able to succesfully drop those values using dropna function. But when I checked the null values again using df.isnull().sum(),it shows me the same null values

Can anyone help?

My code

Ch3steR
  • 20,090
  • 4
  • 28
  • 58
IshPandey
  • 11
  • 1
  • There are other columns associated with which are not null where age appears to be null. Hence the rows are not completely dropped. If you want to drop the rows that where age is null, use inp0.dropna(inplace=True) and check. This will delete rows if any value is null. Check https://stackoverflow.com/questions/13413590/how-to-drop-rows-of-pandas-dataframe-whose-value-in-a-certain-column-is-nan as well. – Abhay Jul 19 '20 at 12:55
  • 1
    `inp0.dropna(subset= ['age'])`? – Ch3steR Jul 19 '20 at 12:57

1 Answers1

0

When you select a column, you cannot dropna and expect it to affect the original data frame.

Use this:

inp0.dropna(subset=['age'], inplace=True)
Pramote Kuacharoen
  • 1,496
  • 1
  • 5
  • 6