def try_convert2float(obj, default=None):
    """Try converting "obj" to a float.
    :param obj: the object to be converted:param default: the default return value when conversion fails.
    :param default: the default return value when conversion fails. Type: float.
    :rtype: float or original object.
    """
    if isinstance(obj, float):
        return obj
    elif isinstance(obj, (bool, int)):
        return float(obj)
    elif isinstance(obj, str):
        obj = obj.strip()
        if obj:
            minus = '-' == obj[0]
            dot = 1 == obj.count('.')
            if minus and dot:
                if obj[1:].replace('.', '').isnumeric():
                    return float(obj)
            elif minus:
                if obj[1:].isnumeric():
                    return float(obj)
            elif dot:
                if any(obj.split('.')):
                    return float(obj)
            elif obj.isnumeric():
                return float(obj)
    return default if isinstance(default, float) else obj
