I'm trying to think through the most efficient way to do this in python.
Suppose I have a list of tuples:
[('dog',12,2), ('cat',15,1), ('dog',11,1), ('cat',15,2), ('dog',10,3), ('cat',16,3)]
And suppose I have a function which takes two of these tuples and combines them:
def my_reduce(obj1, obj2):
return (obj1[0],max(obj1[1],obj2[1]),min(obj1[2],obj2[2]))
How do I perform an efficient reduce by 'key' where the key here could be the first value, so the final result would be something like:
[('dog',12,1), ('cat',16,1)]