【发布时间】:2016-08-31 01:40:37
【问题描述】:
我有一个OrderedDict:
from collections import OrderedDict
d = OrderedDict([('r', 1), ('s', 5), ('a', 3), ('n', 7), ('y', 2)])
我想根据值范围获取字典值的索引。例如,字典d 的索引应该是数组(或np.array),如下所示:
indices
array([ 0, 3, 2, 4, 1 ], dtype=int64)
索引4是字典中的最大值,索引0是最小值
我试过了:
indices = np.argsort(d.values)
【问题讨论】:
标签: python python-2.7 dictionary indices