def dictlist_convert_to_float ( dict_list : Iterable [ Dict ] , key : str ) -> None : for d in dict_list : try : d [ key ] = float ( d [ key ] ) except ValueError : d [ key ] = None
how to make dictionary values float in python
Process an iterable of dictionaries . For each dictionary d convert ( in place ) d [ key ] to a float . If that fails convert it to None .
def dictlist_convert_to_float(dict_list: Iterable[Dict], key: str) -> None:
    """
    Process an iterable of dictionaries. For each dictionary ``d``, convert
    (in place) ``d[key]`` to a float. If that fails, convert it to ``None``.
    """
    for d in dict_list:
        try:
            d[key] = float(d[key])
        except ValueError:
            d[key] = None