Hello,
I have this dict:
I tried this way:
I have this dict:
od = OrderedDict([(0, 1), (1, 1), (3, 1), (7, 1), (36, 1)])And I am plotting this array with the following line:
plt.bar(range(len(od)), list(od.values()), align='center') plt.xticks(range(len(od)), list(od.keys()),rotation='vertical')IN this example for x axis, I have 0,1,3,7,36. However I don't have 2 between 1 and 3 and I don't have any other numbers between 7 and 36. So I want to update my dict like that:
od=([(0, 1), (1, 1),(2,0), (3, 1), (7, 1), (8,0),(9,0),(10,0),(11,0),...(36, 1)])How can I do that?
I tried this way:
finalarray=np.zeros(60) # or sth larger than max (input dict keys) for k,v in od: print(k,v) finalarray[k]=vAnd I got this error:
Error:TypeError: cannot unpack non-iterable int object