def is_number(s):
    """Based on https://stackoverflow.com/a/40097699/519951

    :param s: string
    :return: True if string is a number
    """
    try:
        num = float(s)
        # check for "nan" floats
        return num == num   # or use `math.isnan(num)`
    except ValueError:
        return False