def rename(row, renaming):
    """Rename keys in a dictionary.

       For each (k,v) in renaming.items(): rename row[k] to row[v].
    """
    if not renaming:
        return row

    for k,v in renaming.items():
        row[v] = row[k]
        del row[k]