dataframe to dict such that one column is the key and the other is the value
df = pd.DataFrame([['p',1,3,2],['q',4,3,2],['r',4,0,9]], columns=['ID','A','B','C'])
df=df[['ID','A','B','C']]
df
ID A B C
0 p 1 3 2
1 q 4 3 2
2 r 4 0 9
your_dict = dict(zip(df.ID, df.B))
your_dict
{'p': 3, 'q': 3, 'r': 0}
Something like this:
In [27]: df
Out[27]:
ID A B C
0 p 1 3 2
1 q 4 3 2
2 r 4 0 9
In [30]: df.set_index('ID',inplace=True)
In [31]: df
Out[31]:
A B C
ID
p 1 3 2
q 4 3 2
r 4 0 9
In [33]: df.to_dict()['B']
Out[33]: {'p': 3, 'q': 3, 'r': 0}