0

I have a data set which comprises of 9.90000000e+01 however, I would like to change them to nans. How would I go about doing this please?

renardo
  • 87
  • 7
  • Possible duplicate of [comparing numpy arrays containing NaN](https://stackoverflow.com/q/10710328/608639) and maybe [What's the difference between nan, NaN and NAN](https://stackoverflow.com/q/17825707/608639). You might also be interested in [Does the np.nan in numpy array occupy memory?](https://stackoverflow.com/q/44624404/608639) – jww Sep 23 '18 at 01:24

1 Answers1

1

If your dataset is called arr, use a mask like this:

arr[arr==99] = np.nan

For example:

>>> arr = np.array([9.90000000e+01,9.90000000e+02,9.90000000e+01])
>>> arr
array([ 99., 990.,  99.])

>>> arr[arr==99] = np.nan
>>> arr
array([ nan, 990.,  nan])
sacuL
  • 49,704
  • 8
  • 81
  • 106