我有一个这样结构的数据集:
In[17]: allIndices
Out[17]:
[{0: 0, 1: 1.4589, 4: 2.4879},
{0: 1.4589, 1: 0, 2: 2.1547},
{1: 2.1547, 2: 0, 3: 4.2114},
{2: 4.2114, 3: 0},
{0: 2.4879, 4: 0}]
我想要在字典列表中找到最高的值。我的做法如下:
def findMax(data):
possiblemax = []
for i in range(len(data)):
temp = list(data[i].values())
tempmax = max(temp)
possiblemax.append(tempmax)
maxValue = max(possiblemax)
return maxValue
这个方案可以工作,但是我处理的数据集非常大,速度有点慢。我想知道是否有更好、更快的方法。
非常感谢。