Make a Dict from the list. Since I use numpy's loadtxt, which I often use, it is numpy_arrray type, but I can use it with list type without any problem. You can create dictionary types such as {"hoge": (hoge1, hoge2, hoge3, ...}.
(memorandum)
list2dict.py
import numpy as np
a,b,c = np.arange(10), np.arange(10)*2, np.arange(10)*3
#-> a: [0 1 2 3 4 5 6 7 8 9]
#-> b: [ 0 2 4 6 8 10 12 14 16 18]
#-> c: [ 0 3 6 9 12 15 18 21 24 27]
_bc = zip(b,c)
result = dict(zip(a,_bc))
#-> {0: (0, 0), 1: (2, 3), 2: (4, 6), 3: (6, 9), 4: (8, 12), 5: (10, 15), 6: (12, 18), 7: (14, 21), 8: (16, 24), 9: (18, 27)}
# result = dict(zip(a,zip(b,c)))But good.
That's it.
Recommended Posts