Assume I have the following data which can be either numpy array or pandas DataFrame:
array([[4092, 3],
[4095, 4],
[4097, 4],
[4124, 1],
[4128, 0],
[4129, 0],
[4131, 5],
[4132, 5],
[4133, 2],
[4134, 2]], dtype=int64)
I would like to get an array containing the minimal values in each category (2nd column). I could loop over each unique values perform the min operation and store the results but I was wondering whether there is a faster and cleaner way to do it.
The output would look like the following:
array([[4092, 3],
[4095, 4],
[4124, 1],
[4128, 0],
[4131, 5],
[4133, 2]], dtype=int64)