Skip to content

Commit be347ea

Browse files
author
craigsdennis
committed
Adds rounds to the study log
1 parent 58faa40 commit be347ea

File tree

1 file changed

+256
-11
lines changed

1 file changed

+256
-11
lines changed

Introduction to NumPy.ipynb

Lines changed: 256 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -621,32 +621,277 @@
621621
},
622622
{
623623
"cell_type": "code",
624-
"execution_count": 31,
624+
"execution_count": 32,
625+
"metadata": {},
626+
"outputs": [],
627+
"source": [
628+
"study_minutes[2:6] = [80, 60, 30, 90]"
629+
]
630+
},
631+
{
632+
"cell_type": "markdown",
633+
"metadata": {},
634+
"source": [
635+
"## Creation\n",
636+
"* Random state\n",
637+
"* Appending rows\n",
638+
"\n",
639+
"## Indexing\n",
640+
"* Shortcut (tuple)\n",
641+
"* Fancy Indexing"
642+
]
643+
},
644+
{
645+
"cell_type": "code",
646+
"execution_count": 33,
647+
"metadata": {},
648+
"outputs": [],
649+
"source": [
650+
"study_minutes = np.array([\n",
651+
" study_minutes,\n",
652+
" np.zeros(100, np.uint16)\n",
653+
"])"
654+
]
655+
},
656+
{
657+
"cell_type": "code",
658+
"execution_count": 34,
659+
"metadata": {},
660+
"outputs": [
661+
{
662+
"data": {
663+
"text/plain": [
664+
"(2, 100)"
665+
]
666+
},
667+
"execution_count": 34,
668+
"metadata": {},
669+
"output_type": "execute_result"
670+
}
671+
],
672+
"source": [
673+
"study_minutes.shape"
674+
]
675+
},
676+
{
677+
"cell_type": "code",
678+
"execution_count": 36,
679+
"metadata": {},
680+
"outputs": [],
681+
"source": [
682+
"# Set round 2 day 1 to 60\n",
683+
"study_minutes[1][0] = 60"
684+
]
685+
},
686+
{
687+
"cell_type": "code",
688+
"execution_count": 37,
689+
"metadata": {},
690+
"outputs": [
691+
{
692+
"data": {
693+
"text/plain": [
694+
"60"
695+
]
696+
},
697+
"execution_count": 37,
698+
"metadata": {},
699+
"output_type": "execute_result"
700+
}
701+
],
702+
"source": [
703+
"study_minutes[1, 0]"
704+
]
705+
},
706+
{
707+
"cell_type": "code",
708+
"execution_count": 38,
709+
"metadata": {},
710+
"outputs": [
711+
{
712+
"data": {
713+
"text/plain": [
714+
"(1, 0)"
715+
]
716+
},
717+
"execution_count": 38,
718+
"metadata": {},
719+
"output_type": "execute_result"
720+
}
721+
],
722+
"source": [
723+
"1, 0"
724+
]
725+
},
726+
{
727+
"cell_type": "code",
728+
"execution_count": 39,
625729
"metadata": {},
626730
"outputs": [
627731
{
628732
"data": {
629733
"text/plain": [
630-
"array([150, 60, 80, 60, 30, 90, 0, 0, 0, 0, 0, 0, 0,\n",
631-
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
632-
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
633-
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
634-
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
635-
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
636-
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
637-
" 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=uint16)"
734+
"array([132, 122, 128, 44, 136, 129, 101, 95, 50, 132, 151, 64, 104,\n",
735+
" 175, 117, 146, 139, 129, 133, 176, 98, 160, 179, 99, 82, 142,\n",
736+
" 31, 106, 117, 56, 98, 67, 121, 159, 81, 170, 31, 50, 49,\n",
737+
" 87, 179, 51, 116, 177, 118, 78, 171, 117, 88, 123, 102, 44,\n",
738+
" 79, 31, 108, 80, 59, 137, 84, 93, 155, 160, 67, 80, 166,\n",
739+
" 164, 70, 50, 102, 113, 47, 131, 161, 118, 82, 89, 81, 43,\n",
740+
" 81, 38, 119, 52, 82, 31, 159, 57, 113, 71, 121, 140, 91,\n",
741+
" 70, 37, 106, 64, 127, 110, 58, 93, 79], dtype=uint16)"
638742
]
639743
},
640-
"execution_count": 31,
744+
"execution_count": 39,
745+
"metadata": {},
746+
"output_type": "execute_result"
747+
}
748+
],
749+
"source": [
750+
"rand = np.random.RandomState(42)\n",
751+
"fake_log = rand.randint(30, 180, size=100, dtype=np.uint16)\n",
752+
"fake_log"
753+
]
754+
},
755+
{
756+
"cell_type": "code",
757+
"execution_count": 40,
758+
"metadata": {},
759+
"outputs": [
760+
{
761+
"data": {
762+
"text/plain": [
763+
"[44, 50]"
764+
]
765+
},
766+
"execution_count": 40,
767+
"metadata": {},
768+
"output_type": "execute_result"
769+
}
770+
],
771+
"source": [
772+
"[fake_log[3], fake_log[8]]"
773+
]
774+
},
775+
{
776+
"cell_type": "code",
777+
"execution_count": 41,
778+
"metadata": {},
779+
"outputs": [
780+
{
781+
"data": {
782+
"text/plain": [
783+
"array([44, 50], dtype=uint16)"
784+
]
785+
},
786+
"execution_count": 41,
787+
"metadata": {},
788+
"output_type": "execute_result"
789+
}
790+
],
791+
"source": [
792+
"fake_log[[3, 8]]"
793+
]
794+
},
795+
{
796+
"cell_type": "code",
797+
"execution_count": 42,
798+
"metadata": {},
799+
"outputs": [
800+
{
801+
"data": {
802+
"text/plain": [
803+
"array([[ 44, 50],\n",
804+
" [132, 122]], dtype=uint16)"
805+
]
806+
},
807+
"execution_count": 42,
808+
"metadata": {},
809+
"output_type": "execute_result"
810+
}
811+
],
812+
"source": [
813+
"index = np.array([\n",
814+
" [3, 8],\n",
815+
" [0, 1]\n",
816+
"])\n",
817+
"fake_log[index]"
818+
]
819+
},
820+
{
821+
"cell_type": "code",
822+
"execution_count": 44,
823+
"metadata": {},
824+
"outputs": [],
825+
"source": [
826+
"study_minutes = np.append(study_minutes, [fake_log], axis=0)"
827+
]
828+
},
829+
{
830+
"cell_type": "code",
831+
"execution_count": 46,
832+
"metadata": {},
833+
"outputs": [],
834+
"source": [
835+
"study_minutes[1, 1] = 360"
836+
]
837+
},
838+
{
839+
"cell_type": "code",
840+
"execution_count": 47,
841+
"metadata": {},
842+
"outputs": [
843+
{
844+
"data": {
845+
"text/plain": [
846+
"array([[150, 60, 80, 60, 30, 90, 0, 0, 0, 0, 0, 0, 0,\n",
847+
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
848+
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
849+
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
850+
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
851+
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
852+
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
853+
" 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
854+
" [ 60, 360, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
855+
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
856+
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
857+
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
858+
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
859+
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
860+
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
861+
" 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
862+
" [132, 122, 128, 44, 136, 129, 101, 95, 50, 132, 151, 64, 104,\n",
863+
" 175, 117, 146, 139, 129, 133, 176, 98, 160, 179, 99, 82, 142,\n",
864+
" 31, 106, 117, 56, 98, 67, 121, 159, 81, 170, 31, 50, 49,\n",
865+
" 87, 179, 51, 116, 177, 118, 78, 171, 117, 88, 123, 102, 44,\n",
866+
" 79, 31, 108, 80, 59, 137, 84, 93, 155, 160, 67, 80, 166,\n",
867+
" 164, 70, 50, 102, 113, 47, 131, 161, 118, 82, 89, 81, 43,\n",
868+
" 81, 38, 119, 52, 82, 31, 159, 57, 113, 71, 121, 140, 91,\n",
869+
" 70, 37, 106, 64, 127, 110, 58, 93, 79]], dtype=uint16)"
870+
]
871+
},
872+
"execution_count": 47,
641873
"metadata": {},
642874
"output_type": "execute_result"
643875
}
644876
],
645877
"source": [
646-
"study_minutes[2:6] = [80, 60, 30, 90]\n",
647878
"study_minutes"
648879
]
649880
},
881+
{
882+
"cell_type": "code",
883+
"execution_count": null,
884+
"metadata": {},
885+
"outputs": [],
886+
"source": []
887+
},
888+
{
889+
"cell_type": "code",
890+
"execution_count": null,
891+
"metadata": {},
892+
"outputs": [],
893+
"source": []
894+
},
650895
{
651896
"cell_type": "code",
652897
"execution_count": null,

0 commit comments

Comments
 (0)