← numpy-100

First master exercise

efa490b06ee32fed7595ce50d393d1f61b7dc9c4 · Nicolas Rougier · May 27, 2014 22:01

+13 · 1 file changed

  • README.rst +13 −0
diff --git a/README.rst b/README.rst
index 7dd3038..f942beb 100644
--- a/README.rst
+++ b/README.rst
@@ -563,6 +563,19 @@ Master
 ======
 
 
+1. Given a two dimensional array, how to extract unique rows ?
+
+   .. code:: python
+
+      # Jaime Fernández del Río
+
+      Z = np.random.randint(0,2,(6,6))
+      T = np.ascontiguousarray(Z).view(np.dtype((np.void, Z.dtype.itemsize * Z.shape[1])))
+      _, idx = np.unique(T, return_index=True)
+      uZ = Z[idx]
+
+   .. note:: See `stackoverflow <http://stackoverflow.com/questions/16970982/find-unique-rows-in-numpy-array/>`_ for explanations.
+
 
 Archmaster
 ==========