import math import numpy as np import pandas as pd def nully(obj: any) -> bool: """Checks for all kinds of NaN, NaT and None Args: obj[any]: Object to check Returns: bool: True if obj is nully """ conditions: List[bool] = [ obj is None, # python None obj is np.nan, # numpy NaN obj is pd.nan, # pandas NA, obj is pd.NaT # pandas NaT ] try: conditions.append(math.isnan(obj)) # python NaN except TypeError: # not a number type pass if any(conditions): return True return False
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter