import math


def is_nan(val):
    """Test if a value is NaN

    Parameters
    ----------
    val : obj
        A value

    Returns
    -------
    bool
        Is it NaN?
    """
    try:
        float(val)
        if math.isnan(float(val)):
            return True
    except (ValueError, TypeError):
        pass

    return False