1

I had applied df.fillna(0) to Datafarm df read from CSV file to fillout NaN with 0 but it not works here is my code for reading and apply fillna method.

I have checked here on Pandas website and all was same. Also some similar question on Stackoverflow like this and this. all checked not helped

import pandas as pd
df=pd.read_csv(path to CSV file, header=None)
df.fillna(0)
print(df)
Mohsen
  • 1,079
  • 2
  • 8
  • 23
MHY
  • 43
  • 4

1 Answers1

3

Try this:

only change df.fillna(0, inplace = True)

import pandas as pd
df=pd.read_csv(path to CSV file, header=None)
df.fillna(0, inplace = True)
print(df)
Mohsen
  • 1,079
  • 2
  • 8
  • 23