Oscar Benjamin wrote: > On 24 January 2016 at 17:24, Peter Otten <__pete...@web.de> wrote: >> >> I'm an amateur with numpy, and unfortunately my favourite search engine >> didn't come up with a numpy-specific way to group rows in a 2D array. > > What do you mean by "group rows"?
Given a table you can specify columns as keys and in the simplest case one column where you apply an aggregate function over the sets of rows with the same key. If I understand you correctly you are doing that for a single known key, whereas I considered finding the keys part of the task. In SQL you'd spell that [prob 1] select key1, key2, sum(value) from some_table group by key1, key2; > I thought the OP's problem is really to filter rows which I already > showed how to do in numpy. You solve [prob 2] select sum(value) from some_table where key1=? and key2=?; You'll eventually get from [prob 2] to [prob 1], but you need a few lines of Python. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor