Fast check for NaN in NumPy

后端 未结 7 1856
时光说笑
时光说笑 2021-01-30 02:39

I\'m looking for the fastest way to check for the occurrence of NaN (np.nan) in a NumPy array X. np.isnan(X) is out of the question, since

7条回答
  •  不思量自难忘°
    2021-01-30 03:18

    1. use .any()

      if numpy.isnan(myarray).any()

    2. numpy.isfinite maybe better than isnan for checking

      if not np.isfinite(prop).all()

提交回复
热议问题