Merge a list of dicts, summing their values.
499724
def _count(dicts):
    
    counts = defaultdict(int)
    for d in dicts:
        for k, v in d.items():
            counts[k] += v
    return counts
409005
def deep_merge(*dicts):
    
    result = {}
    for d in dicts:
        if not isinstance(d, dict):
            raise Exception('Can only deep_merge dicts, got {}'.format(d))
        for k, v in d.items():
            # Whenever the value is a dict, we deep_merge it. This ensures that
            # (a) we only ever merge dicts with dicts and (b) we always get a
            # deep(ish) copy of the dicts and are thus safe from accidental
            # mutations to shared state.
            if isinstance(v, dict):
                v = deep_merge(result.get(k, {}), v)
            result[k] = v
    return result
16197
def merge_dicts(dict1, dict2, deep_merge=True):
    """"""
    if deep_merge:
        if isinstance(dict1, list) and isinstance(dict2, list):
            return dict1 + dict2

        if not isinstance(dict1, dict) or not isinstance(dict2, dict):
            return dict2

        for key in dict2:
            dict1[key] = merge_dicts(dict1[key], dict2[key]) if key in dict1 else dict2[key]  # noqa pylint: disable=line-too-long
        return dict1
    dict3 = dict1.copy()
    dict3.update(dict2)
    return dict3
1319370
def dictmerge(x, y):
    
    z = x.copy()
    z.update(y)
    return z
376554
def merge_dictionaries(a, b):
  """"""
  res = {}
  for k in a:
    res[k] = a[k]
  for k in b:
    res[k] = b[k]
  return res
980459
def _merge_data(self, data: AnyMapping, *additional: AnyMapping) -> dict:
        
        """
        return defaults(
            dict(data) if not isinstance(data, dict) else data,
            *(dict(item) for item in additional))
1150342
def merge_dict(a, b):
    
    c = a.copy()
    c.update(b)
    return c
1281831
def _merge_default_values(self):
        """"""
        values = self._get_default_values()
        for key, value in values.items():
            if not self.data.get(key):
                self.data[key] = value
237445
def merge_values(values1,values2):
    '''
    
    '''
    array1 = values_to_array(values1)
    array2 = values_to_array(values2)

    if array1.size == 0:
        return array2
    if array2.size == 0:
        return array1

    merged_array = []
    for row_array1 in array1:
        for row_array2 in array2:
            merged_row = np.hstack((row_array1,row_array2))
            merged_array.append(merged_row)
    return np.atleast_2d(merged_array)
815770
def merge_dicts(i):
    

    a=i['dict1']
    b=i['dict2']

    for k in b:
        v=b[k]
        if type(v) is dict:
           if k not in a:
              a.update({k:b[k]})
           elif type(a[k])==dict:
              merge_dicts({'dict1':a[k], 'dict2':b[k]})
           else:
              a[k]=b[k]
        elif type(v) is list:
           a[k]=[]
           for y in v:
               a[k].append(y)
        else:
           a[k]=b[k]

    return {'return':0, 'dict1':a}
685141
def merge_dicts(dict1, dict2, append_lists=False):
    
    for key in dict2:
        if isinstance(dict2[key], dict):
            if key in dict1 and key in dict2:
                merge_dicts(dict1[key], dict2[key], append_lists)
            else:
                dict1[key] = dict2[key]
        # If the value is a list and the ``append_lists`` flag is set,
        # append the new values onto the original list
        elif isinstance(dict2[key], list) and append_lists:
            # The value in dict1 must be a list in order to append new
            # values onto it. Don't add duplicates.
            if key in dict1 and isinstance(dict1[key], list):
                dict1[key].extend(
                    [k for k in dict2[key] if k not in dict1[key]])
            else:
                dict1[key] = dict2[key]
        else:
            dict1[key] = dict2[key]
999697
def merge(self, other):
        
        ignore = self.ignore
        extra = self.extras
        if isinstance(other, Dict):
            other_keys = other.keys
            ignore += other.ignore
            extra += other.extras
        elif isinstance(other, (list, tuple)):
            other_keys = list(other)
        elif isinstance(other, dict):
            return self.__class__(other, *self.keys)
        else:
            raise TypeError('You must merge Dict only with Dict'
                            ' or list of Keys')
        return self.__class__(*(self.keys + other_keys), ignore_extra=ignore,
                              allow_extra=extra)
415260
def dict_union_combine(dict1, dict2, combine_op=op.add,
                       default=util_const.NoParam,
                       default2=util_const.NoParam):
    
    keys3 = set(dict1.keys()).union(set(dict2.keys()))
    if default is util_const.NoParam:
        dict3 = {key: combine_op(dict1[key], dict2[key]) for key in keys3}
    else:
        if default2 is util_const.NoParam:
            default2 = default
        dict3 = {key: combine_op(dict1.get(key, default), dict2.get(key, default2))
                 for key in keys3}
    return dict3
900555
def _merge_last(values, merge_after, merge_with=' '):
    '''
    
    '''
    if len(values) > merge_after:
        values = values[0:(merge_after-1)] + [merge_with.join(values[(merge_after-1):])]

    return values
792509
def merge_dicts(dict_a, dict_b):
    
    def _merge_dicts_(a, b):
        for key in set(a.keys()).union(b.keys()):
            if key in a and key in b:
                if isinstance(a[key], dict) and isinstance(b[key], dict):
                    yield (key, dict(_merge_dicts_(a[key], b[key])))
                elif b[key] is not None:
                    yield (key, b[key])
                else:
                    yield (key, a[key])
            elif key in a:
                yield (key, a[key])
            elif b[key] is not None:
                yield (key, b[key])
    return dict(_merge_dicts_(dict_a, dict_b))
42617
def combine_numeric_values(self, other):
        
        if self.values is None:
            ret = IdValues()
        else:
            ret = sum([IdValues(
                {k: int(v) * int(other.values[key]) for k, v in value.items()})
                for key, value in self.values.items()])
        return ret
1074324
def merge_dicts(dicts):
        
        merged = {}
        for d in reversed(dicts):
            merged.update(d)
        return merged