def remove_out_of_range(df, range_list):
    """Set any values out of range to NAN.

    Args:
        - df: a wide format df (e.g. the result of data_loader)
        - range_list: a list of dictionaries. Each dictionary has three keys 'variable', 'high' and 'low'.
                        e.g. {'variable': 'aao2', 'high': 700., 'low':10.}
    Returns:
        - df: dataset with invalid values set to NAN
    """
    if range_list is None:
        return df
    for f in range_list:
        if f["variable"] in df.columns:
            col = df[f["variable"]]
            df[f["variable"]] = col.mask((col < f["low"]) | (col > f["high"]))
    return df