Skip to content

Commit d8ba7b4

Browse files
authored
Merge b24dee6 into e8ff5e2
2 parents e8ff5e2 + b24dee6 commit d8ba7b4

File tree

1 file changed

+118
-43
lines changed

1 file changed

+118
-43
lines changed

core/numpy/numpy-basics.ipynb

Lines changed: 118 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,17 @@
2727
"1. Inspecting an array with slicing and indexing"
2828
]
2929
},
30-
{
31-
"cell_type": "markdown",
32-
"metadata": {},
33-
"source": [
34-
"## Prerequisites\n",
35-
"\n",
36-
"| Concepts | Importance | Notes |\n",
37-
"| --- | --- | --- |\n",
38-
"| [Python Quickstart](../../foundations/quickstart) | Necessary | Lists, indexing, slicing, math |\n",
39-
"\n",
40-
"* **Time to learn**: 35 minutes\n",
41-
"---"
42-
]
43-
},
4430
{
4531
"cell_type": "markdown",
4632
"metadata": {},
4733
"source": [
4834
"## Imports\n",
49-
"A common convention you might encounter is to rename `numpy` to `np` on import to shorten it for the many times we will be calling on `numpy` for functionality."
35+
"You need to import packages into your notebook to be able to use them. A common convention you might encounter is to rename `numpy` to `np` on import to shorten it for the many times we will be calling on `numpy` for functionality."
5036
]
5137
},
5238
{
5339
"cell_type": "code",
54-
"execution_count": null,
40+
"execution_count": 1,
5541
"metadata": {},
5642
"outputs": [],
5743
"source": [
@@ -64,14 +50,25 @@
6450
"source": [
6551
"## Create an array of 'data'\n",
6652
"\n",
67-
"The NumPy array represents a *contiguous* block of memory, holding entries of a given type (and hence fixed size). The entries are laid out in memory according to the shape, or list of dimension sizes. Let's start by creating an array from a list of integers and taking a look at it,"
53+
"The NumPy array represents a *contiguous* block of memory, holding entries of a given type (and hence fixed size). Let's start by creating an array from a list of integers and taking a look at it,"
6854
]
6955
},
7056
{
7157
"cell_type": "code",
72-
"execution_count": null,
73-
"metadata": {},
74-
"outputs": [],
58+
"execution_count": 2,
59+
"metadata": {},
60+
"outputs": [
61+
{
62+
"data": {
63+
"text/plain": [
64+
"array([1, 2, 3])"
65+
]
66+
},
67+
"execution_count": 2,
68+
"metadata": {},
69+
"output_type": "execute_result"
70+
}
71+
],
7572
"source": [
7673
"a = np.array([1, 2, 3])\n",
7774
"a"
@@ -81,23 +78,45 @@
8178
"cell_type": "markdown",
8279
"metadata": {},
8380
"source": [
84-
"We can inspect the number of dimensions our array is organized along with `ndim`, and how long each of these dimensions are with `shape`"
81+
"The entries of the array are laid out in memory according to the shape, or list of dimension sizes. We can inspect the number of dimensions of our array with `ndim`, and how long each of these dimensions are with `shape`. "
8582
]
8683
},
8784
{
8885
"cell_type": "code",
89-
"execution_count": null,
90-
"metadata": {},
91-
"outputs": [],
86+
"execution_count": 3,
87+
"metadata": {},
88+
"outputs": [
89+
{
90+
"data": {
91+
"text/plain": [
92+
"1"
93+
]
94+
},
95+
"execution_count": 3,
96+
"metadata": {},
97+
"output_type": "execute_result"
98+
}
99+
],
92100
"source": [
93101
"a.ndim"
94102
]
95103
},
96104
{
97105
"cell_type": "code",
98-
"execution_count": null,
99-
"metadata": {},
100-
"outputs": [],
106+
"execution_count": 4,
107+
"metadata": {},
108+
"outputs": [
109+
{
110+
"data": {
111+
"text/plain": [
112+
"(3,)"
113+
]
114+
},
115+
"execution_count": 4,
116+
"metadata": {},
117+
"output_type": "execute_result"
118+
}
119+
],
101120
"source": [
102121
"a.shape"
103122
]
@@ -106,14 +125,25 @@
106125
"cell_type": "markdown",
107126
"metadata": {},
108127
"source": [
109-
"So our 1-dimensional array has a shape of `3` along that dimension! Finally we can check out the underlying type of our underlying data,"
128+
"So our 1-dimensional array has a shape of `3` along that dimension! The dot `(.)` notation helps you access various `properties` of the NumPy array. Finally, we can check out the underlying type of our underlying data,"
110129
]
111130
},
112131
{
113132
"cell_type": "code",
114-
"execution_count": null,
115-
"metadata": {},
116-
"outputs": [],
133+
"execution_count": 5,
134+
"metadata": {},
135+
"outputs": [
136+
{
137+
"data": {
138+
"text/plain": [
139+
"dtype('int64')"
140+
]
141+
},
142+
"execution_count": 5,
143+
"metadata": {},
144+
"output_type": "execute_result"
145+
}
146+
],
117147
"source": [
118148
"a.dtype"
119149
]
@@ -127,37 +157,82 @@
127157
},
128158
{
129159
"cell_type": "code",
130-
"execution_count": null,
131-
"metadata": {},
132-
"outputs": [],
160+
"execution_count": 6,
161+
"metadata": {},
162+
"outputs": [
163+
{
164+
"data": {
165+
"text/plain": [
166+
"array([[1., 2., 3.],\n",
167+
" [4., 5., 6.]])"
168+
]
169+
},
170+
"execution_count": 6,
171+
"metadata": {},
172+
"output_type": "execute_result"
173+
}
174+
],
133175
"source": [
134176
"a = np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])\n",
135177
"a"
136178
]
137179
},
138180
{
139181
"cell_type": "code",
140-
"execution_count": null,
141-
"metadata": {},
142-
"outputs": [],
182+
"execution_count": 7,
183+
"metadata": {},
184+
"outputs": [
185+
{
186+
"data": {
187+
"text/plain": [
188+
"2"
189+
]
190+
},
191+
"execution_count": 7,
192+
"metadata": {},
193+
"output_type": "execute_result"
194+
}
195+
],
143196
"source": [
144197
"a.ndim"
145198
]
146199
},
147200
{
148201
"cell_type": "code",
149-
"execution_count": null,
150-
"metadata": {},
151-
"outputs": [],
202+
"execution_count": 8,
203+
"metadata": {},
204+
"outputs": [
205+
{
206+
"data": {
207+
"text/plain": [
208+
"(2, 3)"
209+
]
210+
},
211+
"execution_count": 8,
212+
"metadata": {},
213+
"output_type": "execute_result"
214+
}
215+
],
152216
"source": [
153217
"a.shape"
154218
]
155219
},
156220
{
157221
"cell_type": "code",
158-
"execution_count": null,
159-
"metadata": {},
160-
"outputs": [],
222+
"execution_count": 9,
223+
"metadata": {},
224+
"outputs": [
225+
{
226+
"data": {
227+
"text/plain": [
228+
"dtype('float64')"
229+
]
230+
},
231+
"execution_count": 9,
232+
"metadata": {},
233+
"output_type": "execute_result"
234+
}
235+
],
161236
"source": [
162237
"a.dtype"
163238
]

0 commit comments

Comments
 (0)