-1

I am working on this dataset and in one of the columns (LotFrontage) has 259 Nan values out of 1460. So when I use X.describe() it shows 259 nulls. I tried to fill those null values with 0's.. using isnull(). Once I view the result all the Nan values are correctly filled with zeros. But the problem is, when I run X.describe() again, it still shows 259 nan values. What am I doing wrong ? Any help please?

Darren76
  • 11
  • 2
  • try using `inplace` as `df['colname'].fillna(0, inplace=True)`. For more explanation check https://stackoverflow.com/questions/13295735/how-can-i-replace-all-the-nan-values-with-zeros-in-a-column-of-a-pandas-datafra – meW Jan 08 '19 at 06:20
  • 1
    Thank you so much. I just tried it and it worked. Sorry I didn't see that a similar question had been asked already. Thank you again! – Darren76 Jan 08 '19 at 06:27

1 Answers1

0

Pandas don't change the actual DataFrame. If you want to change in actual DataFrame you have to pass in-place argument as True

<your_dataframe>.fillna(value = 0, inplace = True)
Manish Patel
  • 3,648
  • 1
  • 14
  • 22
Ujjwal Gupta
  • 156
  • 5