Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d241a74

Browse files
author
craigsdennis
committed
Talk about common routines, mean and sum and their axis parameter
1 parent 02064a9 commit d241a74

File tree

1 file changed

+177
-0
lines changed

1 file changed

+177
-0
lines changed

‎Introduction to NumPy.ipynb

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,75 @@
459459
"students_gpas[2][3]"
460460
]
461461
},
462+
{
463+
"cell_type": "code",
464+
"execution_count": 85,
465+
"metadata": {},
466+
"outputs": [
467+
{
468+
"data": {
469+
"text/plain": [
470+
"array([[4. , 3.285, 3.5 , 4. ],\n",
471+
" [3.2 , 3.8 , 4. , 4. ],\n",
472+
" [3.96 , 3.92 , 4. , 4. ]], dtype=float16)"
473+
]
474+
},
475+
"execution_count": 85,
476+
"metadata": {},
477+
"output_type": "execute_result"
478+
}
479+
],
480+
"source": [
481+
"students_gpas"
482+
]
483+
},
484+
{
485+
"cell_type": "code",
486+
"execution_count": 86,
487+
"metadata": {},
488+
"outputs": [
489+
{
490+
"data": {
491+
"text/plain": [
492+
"3.805"
493+
]
494+
},
495+
"execution_count": 86,
496+
"metadata": {},
497+
"output_type": "execute_result"
498+
}
499+
],
500+
"source": [
501+
"students_gpas.mean()"
502+
]
503+
},
504+
{
505+
"cell_type": "code",
506+
"execution_count": 89,
507+
"metadata": {},
508+
"outputs": [
509+
{
510+
"data": {
511+
"text/plain": [
512+
"array([3.695, 3.75 , 3.97 ], dtype=float16)"
513+
]
514+
},
515+
"execution_count": 89,
516+
"metadata": {},
517+
"output_type": "execute_result"
518+
}
519+
],
520+
"source": [
521+
"students_gpas.mean(axis=1)"
522+
]
523+
},
524+
{
525+
"cell_type": "code",
526+
"execution_count": null,
527+
"metadata": {},
528+
"outputs": [],
529+
"source": []
530+
},
462531
{
463532
"cell_type": "code",
464533
"execution_count": null,
@@ -1015,6 +1084,114 @@
10151084
"study_minutes[2]"
10161085
]
10171086
},
1087+
{
1088+
"cell_type": "code",
1089+
"execution_count": 91,
1090+
"metadata": {},
1091+
"outputs": [
1092+
{
1093+
"data": {
1094+
"text/plain": [
1095+
"440"
1096+
]
1097+
},
1098+
"execution_count": 91,
1099+
"metadata": {},
1100+
"output_type": "execute_result"
1101+
}
1102+
],
1103+
"source": [
1104+
"np.add.reduce(study_minutes[0])"
1105+
]
1106+
},
1107+
{
1108+
"cell_type": "code",
1109+
"execution_count": 92,
1110+
"metadata": {},
1111+
"outputs": [
1112+
{
1113+
"data": {
1114+
"text/plain": [
1115+
"array([150, 210, 290, 350, 350, 440, 440, 440, 440, 440, 440, 440, 440,\n",
1116+
" 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440,\n",
1117+
" 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440,\n",
1118+
" 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440,\n",
1119+
" 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440,\n",
1120+
" 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440,\n",
1121+
" 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440, 440,\n",
1122+
" 440, 440, 440, 440, 440, 440, 440, 440, 440], dtype=uint64)"
1123+
]
1124+
},
1125+
"execution_count": 92,
1126+
"metadata": {},
1127+
"output_type": "execute_result"
1128+
}
1129+
],
1130+
"source": [
1131+
"np.add.accumulate(study_minutes[0])"
1132+
]
1133+
},
1134+
{
1135+
"cell_type": "code",
1136+
"execution_count": 93,
1137+
"metadata": {},
1138+
"outputs": [
1139+
{
1140+
"data": {
1141+
"text/plain": [
1142+
"440"
1143+
]
1144+
},
1145+
"execution_count": 93,
1146+
"metadata": {},
1147+
"output_type": "execute_result"
1148+
}
1149+
],
1150+
"source": [
1151+
"np.sum(study_minutes[0])"
1152+
]
1153+
},
1154+
{
1155+
"cell_type": "code",
1156+
"execution_count": 95,
1157+
"metadata": {},
1158+
"outputs": [
1159+
{
1160+
"data": {
1161+
"text/plain": [
1162+
"array([ 440, 420, 9290], dtype=uint64)"
1163+
]
1164+
},
1165+
"execution_count": 95,
1166+
"metadata": {},
1167+
"output_type": "execute_result"
1168+
}
1169+
],
1170+
"source": [
1171+
"np.sum(study_minutes, axis=1)"
1172+
]
1173+
},
1174+
{
1175+
"cell_type": "code",
1176+
"execution_count": null,
1177+
"metadata": {},
1178+
"outputs": [],
1179+
"source": []
1180+
},
1181+
{
1182+
"cell_type": "code",
1183+
"execution_count": null,
1184+
"metadata": {},
1185+
"outputs": [],
1186+
"source": []
1187+
},
1188+
{
1189+
"cell_type": "code",
1190+
"execution_count": null,
1191+
"metadata": {},
1192+
"outputs": [],
1193+
"source": []
1194+
},
10181195
{
10191196
"cell_type": "markdown",
10201197
"metadata": {},

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /