See the docs for to_dict
. You can use it like this:
df.set_index('id').to_dict()
And if you have only one column, to avoid the column name is also a level in the dict (actually, in this case you use the Series.to_dict()
):
df.set_index('id')['value'].to_dict()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…