0

I am working on Jupyter, I have a large dataset which contains missing values. I have replaced the question mark to NaN, but when I am counting the missing values in the dataset, the command is not executing as it returns 0 value.. I have tried this command, but not succeed:

print(com.isnull().sum())

Replaced question mark by NaN:

Returning 0 value:

Omar Einea
  • 2,478
  • 7
  • 23
  • 35
Jack
  • 53
  • 1
  • 8
  • The problem is actually with `replace`. If you print your dataframe after it, you will see that it didn't work. See [here](https://stackoverflow.com/questions/37593550/pandas-replacing-elements-not-working) for explanation – Georgy Mar 04 '18 at 16:16

1 Answers1

1

By default, replace does not modify the dataframe in-place. Instead, it returns a dataframe with the modifications made.


Just change the relevant line of code to:

com.replace('?', np.NaN, inplace=True)
nisemonoxide
  • 441
  • 2
  • 7