Skip to content

Instantly share code, notes, and snippets.

@sharkdeng
Last active October 9, 2020 11:16
Show Gist options
  • Save sharkdeng/0a530716497b33fdbb26987a70a5b0f9 to your computer and use it in GitHub Desktop.
Save sharkdeng/0a530716497b33fdbb26987a70a5b0f9 to your computer and use it in GitHub Desktop.
judge if the given value is nan
def is_nan(a):
import math
import numpy as np
if isinstance(a, float):
return math.isnan(a)
elif isinstance(a, np.float64):
return np.isnan(a)
else:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment