Compare commits
8 Commits
564a329151
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e865a958ed | ||
|
|
a4bf63e6bc | ||
|
|
d421b9750c | ||
|
|
4a3372ed11 | ||
|
|
6447594ad6 | ||
|
|
9642cab77c | ||
|
|
4ccd5c0689 | ||
|
|
bfd5e4dbcb |
File diff suppressed because it is too large
Load Diff
@@ -131,7 +131,7 @@ Z = np.ones((5,5))
|
|||||||
Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
|
Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
|
||||||
print(Z)
|
print(Z)
|
||||||
|
|
||||||
# Using fancy indexing
|
# Not a solution to this problem but good to know: using fancy indexing for in-place edit
|
||||||
Z[:, [0, -1]] = 0
|
Z[:, [0, -1]] = 0
|
||||||
Z[[0, -1], :] = 0
|
Z[[0, -1], :] = 0
|
||||||
print(Z)
|
print(Z)
|
||||||
@@ -548,7 +548,7 @@ s = StringIO('''1, 2, 3, 4, 5
|
|||||||
|
|
||||||
, , 9,10,11
|
, , 9,10,11
|
||||||
''')
|
''')
|
||||||
Z = np.genfromtxt(s, delimiter=",", dtype=np.int)
|
Z = np.genfromtxt(s, delimiter=",", dtype = int, filling_values = 0)
|
||||||
print(Z)
|
print(Z)
|
||||||
```
|
```
|
||||||
#### 55. What is the equivalent of enumerate for numpy arrays? (★★☆)
|
#### 55. What is the equivalent of enumerate for numpy arrays? (★★☆)
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ Z = np.ones((5,5))
|
|||||||
Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
|
Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
|
||||||
print(Z)
|
print(Z)
|
||||||
|
|
||||||
# Using fancy indexing
|
# Not a solution to this problem but good to know: using fancy indexing for in-place edit
|
||||||
Z[:, [0, -1]] = 0
|
Z[:, [0, -1]] = 0
|
||||||
Z[[0, -1], :] = 0
|
Z[[0, -1], :] = 0
|
||||||
print(Z)
|
print(Z)
|
||||||
@@ -548,7 +548,7 @@ s = StringIO('''1, 2, 3, 4, 5
|
|||||||
|
|
||||||
, , 9,10,11
|
, , 9,10,11
|
||||||
''')
|
''')
|
||||||
Z = np.genfromtxt(s, delimiter=",", dtype=np.int)
|
Z = np.genfromtxt(s, delimiter=",", dtype = int, filling_values = 0)
|
||||||
print(Z)
|
print(Z)
|
||||||
```
|
```
|
||||||
#### 55. What is the equivalent of enumerate for numpy arrays? (★★☆)
|
#### 55. What is the equivalent of enumerate for numpy arrays? (★★☆)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "af9e3994",
|
"id": "a3747e86",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"# 100 numpy exercises\n",
|
"# 100 numpy exercises\n",
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "76e99d49",
|
"id": "8b9ef9a4",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"File automatically generated. See the documentation to update questions/answers/hints programmatically."
|
"File automatically generated. See the documentation to update questions/answers/hints programmatically."
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "8a54b21a",
|
"id": "792c1217",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"Run the `initialise.py` module, then call a random question with `pick()` an hint towards its solution with\n",
|
"Run the `initialise.py` module, then call a random question with `pick()` an hint towards its solution with\n",
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "670bb646",
|
"id": "541f746c",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "4ff49967",
|
"id": "d1743adb",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ Z = np.ones((5,5))
|
|||||||
Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
|
Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
|
||||||
print(Z)
|
print(Z)
|
||||||
|
|
||||||
# Using fancy indexing
|
# Not a solution to this problem but good to know: using fancy indexing for in-place edit
|
||||||
Z[:, [0, -1]] = 0
|
Z[:, [0, -1]] = 0
|
||||||
Z[[0, -1], :] = 0
|
Z[[0, -1], :] = 0
|
||||||
print(Z)
|
print(Z)
|
||||||
@@ -696,7 +696,7 @@ s = StringIO('''1, 2, 3, 4, 5
|
|||||||
|
|
||||||
, , 9,10,11
|
, , 9,10,11
|
||||||
''')
|
''')
|
||||||
Z = np.genfromtxt(s, delimiter=",", dtype=np.int)
|
Z = np.genfromtxt(s, delimiter=",", dtype = int, filling_values = 0)
|
||||||
print(Z)
|
print(Z)
|
||||||
|
|
||||||
< q55
|
< q55
|
||||||
|
|||||||
Reference in New Issue
Block a user