Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. ll = []
  2. for i in tqdm(a.itertuples(index=False), total = len(a)):
  3.     d1 = str(i.d1cid)
  4.     d2 = str(i.d2cid)
  5.     temp = i._asdict() # tranform named tuple into dict
  6.     temp.update({k: int(v) for k,v in enumerate(np.mean([names[d1],names[d2]], axis=0))}) # merge two dict, first - created from named tuple, second - from dict comprehension of enumerating over an array
  7.     ll.append(temp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement