Fast check for NaN in NumPy

后端 未结 7 1853
时光说笑
时光说笑 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:14

    Related to this is the question of how to find the first occurrence of NaN. This is the fastest way to handle that that I know of:

    index = next((i for (i,n) in enumerate(iterable) if n!=n), None)
    

提交回复
热议问题