Applying a function by bins on a vector in Numpy
How would I go about applying an aggregating function (such as "sum()" or "max()") to bins in a vector.

That is if I have:
1. a vector of values x of length N
2. a vector of bin tags b of length N

such that b indicates to what bin each value in x belongs.
for every possible value in b a I want to apply the aggregating function "func()" on all the values of x that belong to that bin.

    >> x = [1,2,3,4,5,6]
    >> b = ["a","b","a","a","c","c"]    

the output should be 2 vectors (say the aggregating function is the product function):

    >>(labels, y) = apply_to_bins(values = x, bins = b, func = prod)

    labels = ["a","b","c"]
    y = [12, 2, 30]

I want to do this as elegantly as possible in numpy (or just python), since obviously I could just "for loop" over it.

Applying a function by bins on a vector in Numpy
===

How would I go about applying an aggregating function (such as "sum()" or "max()") to bins in a vector.

That is if I have:
1. a vector of values x of length N
2. a vector of bin tags b of length N

such that b indicates to what bin each value in x belongs.
for every possible value in b a I want to apply the aggregating function "func()" on all the values of x that belong to that bin.

    >> x = [1,2,3,4,5,6]
    >> b = ["a","b","a","a","c","c"]    

the output should be 2 vectors (say the aggregating function is the product function):

    >>(labels, y) = apply_to_bins(values = x, bins = b, func = prod)

    labels = ["a","b","c"]
    y = [12, 2, 30]

I want to do this as elegantly as possible in numpy (or just python), since obviously I could just "for loop" over it.
