Skip to content

Commit fd44509

Browse files
committed
save changes before rebase
1 parent 72da8a2 commit fd44509

File tree

1 file changed

+70
-19
lines changed

1 file changed

+70
-19
lines changed

Mod1/M1L2-Numpy_STUDENT.ipynb

Lines changed: 70 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
},
3030
{
3131
"cell_type": "code",
32-
"execution_count": null,
32+
"execution_count": 1,
3333
"metadata": {},
3434
"outputs": [],
3535
"source": [
3636
"# Import NumPy \n",
37-
"None"
37+
"import numpy as np"
3838
]
3939
},
4040
{
@@ -49,11 +49,19 @@
4949
},
5050
{
5151
"cell_type": "code",
52-
"execution_count": null,
52+
"execution_count": 2,
5353
"metadata": {},
54-
"outputs": [],
54+
"outputs": [
55+
{
56+
"name": "stdout",
57+
"output_type": "stream",
58+
"text": [
59+
"[1 2 3 4 5]\n"
60+
]
61+
}
62+
],
5563
"source": [
56-
"points = None\n",
64+
"points = np.array([1,2,3,4,5])\n",
5765
"print(points)"
5866
]
5967
},
@@ -70,14 +78,20 @@
7078
},
7179
{
7280
"cell_type": "code",
73-
"execution_count": null,
81+
"execution_count": 4,
7482
"metadata": {},
7583
"outputs": [],
7684
"source": [
7785
"# Create a 2D array for player stats\n",
7886
"# Example: [[points, rebounds, assists], ...]\n",
7987
"\n",
80-
"player_stats = None"
88+
"player_stats = np.array([\n",
89+
" [32, 22, 14],\n",
90+
" [32, 12, 10],\n",
91+
" [5, 2, 10],\n",
92+
" [12, 20, 2],\n",
93+
" [5, 19, 4]\n",
94+
"])\n"
8195
]
8296
},
8397
{
@@ -93,11 +107,20 @@
93107
},
94108
{
95109
"cell_type": "code",
96-
"execution_count": null,
110+
"execution_count": 9,
97111
"metadata": {},
98-
"outputs": [],
112+
"outputs": [
113+
{
114+
"name": "stdout",
115+
"output_type": "stream",
116+
"text": [
117+
"[68 54 17 34 28]\n"
118+
]
119+
}
120+
],
99121
"source": [
100122
"# Calculate total stats for each player\n",
123+
"\n",
101124
"total_stats = np.sum(player_stats, axis=1)\n",
102125
"print(total_stats)"
103126
]
@@ -113,12 +136,22 @@
113136
},
114137
{
115138
"cell_type": "code",
116-
"execution_count": null,
139+
"execution_count": 5,
117140
"metadata": {},
118-
"outputs": [],
141+
"outputs": [
142+
{
143+
"name": "stdout",
144+
"output_type": "stream",
145+
"text": [
146+
"[[32 32 5 12 5]\n",
147+
" [22 12 2 20 19]\n",
148+
" [14 10 10 2 4]]\n"
149+
]
150+
}
151+
],
119152
"source": [
120153
"# Transpose the array\n",
121-
"transposed_stats = None\n",
154+
"transposed_stats = player_stats.transpose()\n",
122155
"print(transposed_stats)"
123156
]
124157
},
@@ -135,13 +168,22 @@
135168
},
136169
{
137170
"cell_type": "code",
138-
"execution_count": null,
171+
"execution_count": 7,
139172
"metadata": {},
140-
"outputs": [],
173+
"outputs": [
174+
{
175+
"name": "stdout",
176+
"output_type": "stream",
177+
"text": [
178+
"[[1. 0.64299603]\n",
179+
" [0.64299603 1. ]]\n"
180+
]
181+
}
182+
],
141183
"source": [
142184
"# Calculate correlation between points and assists -- what does the output mean?\n",
143185
"\n",
144-
"correlation = None(player_stats[:, 0], player_stats[:, 2])\n",
186+
"correlation = np.corrcoef(player_stats[:, 0], player_stats[:, 2])\n",
145187
"print(correlation)"
146188
]
147189
},
@@ -171,9 +213,18 @@
171213
},
172214
{
173215
"cell_type": "code",
174-
"execution_count": null,
216+
"execution_count": 15,
175217
"metadata": {},
176-
"outputs": [],
218+
"outputs": [
219+
{
220+
"name": "stdout",
221+
"output_type": "stream",
222+
"text": [
223+
"Player with the highest total stats: Player 3\n",
224+
"Total stats: 46\n"
225+
]
226+
}
227+
],
177228
"source": [
178229
"# Player stats array\n",
179230
"player_stats = np.array([\n",
@@ -185,10 +236,10 @@
185236
"])\n",
186237
"\n",
187238
"# Calculate total stats for each player\n",
188-
"total_stats = None\n",
239+
"total_stats = np.sum(player_stats, axis=1)\n",
189240
"\n",
190241
"# Find the index of the player with the highest total stats\n",
191-
"best_player_index = None\n",
242+
"best_player_index = np.argmax(total_stats)\n",
192243
"\n",
193244
"# Print the result\n",
194245
"print(f\"Player with the highest total stats: Player {best_player_index + 1}\")\n",

0 commit comments

Comments
 (0)