[Numpy-discussion] Enum/Factor NEP (now with code)

Bryan Van de Ven bryanv@continuum...
Wed Jun 13 17:20:17 CDT 2012


On 6/13/12 5:11 PM, Wes McKinney wrote:
> And retrieving group indicies/summing:
>
> In [8]: %timeit arr=='a'
> 1000 loops, best of 3: 1.52 ms per loop
> In [10]: vals = np.random.randn(1000000)
> In [20]: inds = [arr==x for x in lets]
> In [23]: %timeit for ind in inds: vals[ind].sum()
> 10 loops, best of 3: 48.3 ms per loop
> (FYI you're comparing an O(NK) algorithm with an O(N) algorithm for small K)

I am not familiar with the details of your groupby implementation 
(evidently!), consider me appropriately chastised.

Bryan


More information about the NumPy-Discussion mailing list