[Numpy-discussion] Numpy 'groupby'

Wes McKinney wesmckinn@gmail....
Wed Jan 11 19:27:46 CST 2012

On Wed, Jan 11, 2012 at 7:05 AM, Neal Becker <ndbecker2@gmail.com> wrote:
> Michael Hull wrote:
>> Hi Everyone,
>> First off, thanks for all your hard work on numpy, its a really great help!
>> I was wondering if there was a standard 'groupby' in numpy, that
>> similar to that in itertools.
>> I know its not hard to write with np.diff, but I have found myself
>> writing it on more than a couple of occasions, and wondered if
>>  there was a 'standarised' version I was missing out on??
>> Thanks,
>> Mike
> I've played with groupby in pandas.
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

I agree (unsurprisingly) that pandas is your best bet:


I've had it on my TODO list to extend the pandas groupby engine (which
has grown fairly sophisticated) to work with generic ndarrays and
record arrays:


It shouldn't actually be that hard for most simple cases. I could
imagine the results of a groupby being somewhat difficult to interpret
without axis labeling/indexing, though.


More information about the NumPy-Discussion mailing list