sklearn_utils/utils/data_utils.py
def map_dict(d, key_func=None, value_func=None, if_func=None):
    '''
    :param dict d: dictionary
    :param func key_func: func which will run on key.
    :param func value_func: func which will run on values.
    '''
    key_func = key_func or (lambda k, v: k)
    value_func = value_func or (lambda k, v: v)
    if_func = if_func or (lambda k, v: True)
    return {
        key_func(*k_v): value_func(*k_v)
        for k_v in d.items() if if_func(*k_v)
    }
def map_dict(d, key_func=None, value_func=None, if_func=None):
    '''
    :param dict d: dictionary
    :param func key_func: func which will run on key.
    :param func value_func: func which will run on values.
    '''
    key_func = key_func or (lambda k, v: k)
    value_func = value_func or (lambda k, v: v)
    if_func = if_func or (lambda k, v: True)
    return {
        key_func(*k_v): value_func(*k_v)
        for k_v in d.items() if if_func(*k_v)
    }
:param dict d: dictionary
    :param func key_func: func which will run on key.
    :param func value_func: func which will run on values.