def parse_float ( float_str ) : factor = __get_factor ( float_str ) if factor != 1 : float_str = float_str [ : - 1 ] try : return float ( float_str . replace ( ',' , '' ) ) * factor except ValueError : return None
fraction and whole number string to float python
Parse a string of the form 305 . 48b into a Python float . The terminal letter if present indicates e . g . billions .
def parse_float(float_str):
    """Parse a string of the form 305.48b into a Python float.
       The terminal letter, if present, indicates e.g. billions."""
    factor = __get_factor(float_str)
    if factor != 1:
        float_str = float_str[:-1]

    try:
        return float(float_str.replace(',', '')) * factor
    except ValueError:
        return None