def _dataframe_as_dict(df, key_column, value_column):
    """Given DataFrame(id=[1,2,3], name=['a', 'b', 'c']), this gives
    {1: 'a', 2: 'b', 3: 'c'}.
    """
    return {getattr(row, key_column): getattr(row, value_column) for row in df.itertuples()}