Find A Minimal Value In Each Array In Python
Suppose I have the following data in Python 3.3: my_array = [{'man_id': 1, '_id': ObjectId('1234566'), 'type': 'worker', 'value': 11}, {'man_id': 1, '_id': ObjectId('123457
Solution 1:
[min(arr, key=lambda s:s['value']) for arr in my_array]
Solution 2:
Maybe something like that is acc for you:
for arr in my_array:
minVal = min([row['value'] for row in arr])
print [row for row in arr if row['value'] == minVal]
Post a Comment for "Find A Minimal Value In Each Array In Python"