diff --git a/100 Numpy exercises.ipynb b/100 Numpy exercises.ipynb index 41b06ecb..88798fcc 100644 --- a/100 Numpy exercises.ipynb +++ b/100 Numpy exercises.ipynb @@ -2150,12 +2150,7 @@ "\n", "Z = np.random.randint(0,5,(10,3))\n", "print(Z)\n", - "# solution for arrays of all dtypes (including string arrays and record arrays)\n", - "E = np.all(Z[:,1:] == Z[:,:-1], axis=1)\n", - "U = Z[~E]\n", - "print(U)\n", - "# soluiton for numerical arrays only, will work for any number of columns in Z\n", - "U = Z[Z.max(axis=1) != Z.min(axis=1),:]\n", + "U = Z[~(Z[:,0,None]==Z[:,1:]).all(axis=1)]\n", "print(U)" ] }, diff --git a/100 Numpy exercises.md b/100 Numpy exercises.md index 0877443d..ae1fb484 100644 --- a/100 Numpy exercises.md +++ b/100 Numpy exercises.md @@ -1109,12 +1109,7 @@ print(rows) Z = np.random.randint(0,5,(10,3)) print(Z) -# solution for arrays of all dtypes (including string arrays and record arrays) -E = np.all(Z[:,1:] == Z[:,:-1], axis=1) -U = Z[~E] -print(U) -# soluiton for numerical arrays only, will work for any number of columns in Z -U = Z[Z.max(axis=1) != Z.min(axis=1),:] +U = Z[~(Z[:,0,None]==Z[:,1:]).all(axis=1)] print(U) ```