generalizing the solution to the 'extract rows with unequal values' exercise
This commit is contained in:
parent
733e2c3204
commit
37e7fe2563
@ -2149,9 +2149,7 @@
|
|||||||
"# Author: Robert Kern\n",
|
"# Author: Robert Kern\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Z = np.random.randint(0,5,(10,3))\n",
|
"Z = np.random.randint(0,5,(10,3))\n",
|
||||||
"E = np.logical_and.reduce(Z[:,1:] == Z[:,:-1], axis=1)\n",
|
"U = Z[Z.max(axis=1) != Z.min(axis=1),:]\n",
|
||||||
"U = Z[~E]\n",
|
|
||||||
"print(Z)\n",
|
|
||||||
"print(U)"
|
"print(U)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -1108,9 +1108,7 @@ print(rows)
|
|||||||
# Author: Robert Kern
|
# Author: Robert Kern
|
||||||
|
|
||||||
Z = np.random.randint(0,5,(10,3))
|
Z = np.random.randint(0,5,(10,3))
|
||||||
E = np.logical_and.reduce(Z[:,1:] == Z[:,:-1], axis=1)
|
U = Z[Z.max(axis=1) != Z.min(axis=1),:]
|
||||||
U = Z[~E]
|
|
||||||
print(Z)
|
|
||||||
print(U)
|
print(U)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user