[Numpy-discussion] Picking rows with the first (or last) occurrence of each key

josef.pktd at gmail.com josef.pktd at gmail.com
Tue Jul 5 02:50:13 EDT 2016


On Tue, Jul 5, 2016 at 1:03 AM, Juan Nunez-Iglesias <jni.soma at gmail.com>
wrote:

> On 4 July 2016 at 7:27:47 PM, Skip Montanaro (skip.montanaro at gmail.com)
> wrote:
>
> Hashing it probably wouldn't work, too
> great a chance for collisions.
>
>
> If the string is ASCII, you can always interpret the bytes as part of an 8
> byte integer. Or, you can map unique values to consecutive integers.
>
IIUC

np.nonzero(a[1] == a[:-1])   gives all changes independent of dtype. add or
remove a 1 to adjust which element is indexed.

(IIRC from a long time ago, arraysetops used/uses something like this.)

Josef


>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20160705/580e2295/attachment.html>


More information about the NumPy-Discussion mailing list