import math


def filter_none(mongo_dict):
    """Function to filter out Nones and NaN from a dict."""
    for key in list(mongo_dict.keys()):
        val = mongo_dict[key]
        try:
            if val is None or math.isnan(val):
                mongo_dict.pop(key)
        except Exception:
            continue
    return mongo_dict