python - Getting an array from collections ordereddict for the maximum key, values -
d = collections.ordereddict() d {'a': array([[ 29.503], [ 31.829], [ 13.078], ..., [ 43.227], [ 53.028], [ 43.928]]), 'b': array([[ 28.738], [ 68.151], [ 49.02 ], ..., [ 296.73 ], [ 107.052], [ 87.845]]), 'c': array([[ 11.288], [ 31.343], [ 71.269], ..., [ 92.106], [ 34.668], [ 41.614]])} if want maximum of each value of array a[0], b[0] & c[0], a[1], b[1] & c[1], ...etc. , return array [a, b, c..., b] etc.
then use y = max(d.iterkeys(), key=lambda k: d[k])
then says,
valueerror: truth value of array more 1 element ambiguous. use a.any() or a.all()
so seek if can array [a, b, c..., b] etc.?
thank you
something this:
np.array(list(d.keys()))[np.hstack(d.values()).argmax(axis=1)] #array(['a', 'b', 'c', 'b', 'b', 'b'], # dtype='<u1')
Comments
Post a Comment