Here is my Dictionary:
dict = {'UID1': USER ID Table EMAIL
user1 tbl1 abc
user1 tbl2 abc
user1 tbl3 abc
'UID2': USER ID Table EMAIL
user2 tbl4 efg
user2 tbl5 efg
user2 tbl6 efg}
I would like to iterate over dictionary and fetch Email column first value as abc
for key in dict:
mgr = dict[key]['EMAIL'][1]
print(mgr)
This code gives error: pls help to fetch the correct value.
Pandas count from 0
, so for first value by position use Series.iat
with 0
:
for key, val in dict.items():
mgr = val['EMAIL'].iat[0]
print(mgr)
Or is possible use DataFrame.iat
with position of column EMAIL
by Index.get_loc
:
for key, val in dict.items():
mgr = val.iat[0, val.columns.get_loc('EMAIL')]
print(mgr)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.