Skip to content

Commit 37e7fe2

Browse files
committed
generalizing the solution to the 'extract rows with unequal values' exercise
1 parent 733e2c3 commit 37e7fe2

2 files changed

Lines changed: 2 additions & 6 deletions

File tree

100 Numpy exercises.ipynb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,9 +2149,7 @@
21492149
"# Author: Robert Kern\n",
21502150
"\n",
21512151
"Z = np.random.randint(0,5,(10,3))\n",
2152-
"E = np.logical_and.reduce(Z[:,1:] == Z[:,:-1], axis=1)\n",
2153-
"U = Z[~E]\n",
2154-
"print(Z)\n",
2152+
"U = Z[Z.max(axis=1) != Z.min(axis=1),:]\n",
21552153
"print(U)"
21562154
]
21572155
},

100 Numpy exercises.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,9 +1108,7 @@ print(rows)
11081108
# Author: Robert Kern
11091109

11101110
Z = np.random.randint(0,5,(10,3))
1111-
E = np.logical_and.reduce(Z[:,1:] == Z[:,:-1], axis=1)
1112-
U = Z[~E]
1113-
print(Z)
1111+
U = Z[Z.max(axis=1) != Z.min(axis=1),:]
11141112
print(U)
11151113
```
11161114

0 commit comments

Comments
 (0)