convert pandas DataFrame `df` to a dictionary using `id` field as the key,df.set_index('id').to_dict()