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 8d1fc88

Browse files
author
craigsdennis
committed
Creates list of gpas and explores the new array
1 parent bce0e16 commit 8d1fc88

File tree

1 file changed

+179
-0
lines changed

1 file changed

+179
-0
lines changed

‎Introduction to NumPy.ipynb

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,185 @@
2929
"np.__version__"
3030
]
3131
},
32+
{
33+
"cell_type": "markdown",
34+
"metadata": {},
35+
"source": [
36+
"## Differences between lists and NumPy Arrays\n"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": 3,
42+
"metadata": {},
43+
"outputs": [],
44+
"source": [
45+
"gpas_as_list = [4.0, 3.286, 3.5]"
46+
]
47+
},
48+
{
49+
"cell_type": "code",
50+
"execution_count": 4,
51+
"metadata": {},
52+
"outputs": [
53+
{
54+
"data": {
55+
"text/plain": [
56+
"'Whatevs'"
57+
]
58+
},
59+
"execution_count": 4,
60+
"metadata": {},
61+
"output_type": "execute_result"
62+
}
63+
],
64+
"source": [
65+
"# Can have elements appended to it\n",
66+
"gpas_as_list.append(4.0)\n",
67+
"# Can have multiple datatypes in it.\n",
68+
"gpas_as_list.insert(1, \"Whatevs\")\n",
69+
"# Can have items removed\n",
70+
"gpas_as_list.pop(1)"
71+
]
72+
},
73+
{
74+
"cell_type": "code",
75+
"execution_count": 5,
76+
"metadata": {},
77+
"outputs": [
78+
{
79+
"data": {
80+
"text/plain": [
81+
"[4.0, 3.286, 3.5, 4.0]"
82+
]
83+
},
84+
"execution_count": 5,
85+
"metadata": {},
86+
"output_type": "execute_result"
87+
}
88+
],
89+
"source": [
90+
"gpas_as_list"
91+
]
92+
},
93+
{
94+
"cell_type": "code",
95+
"execution_count": 6,
96+
"metadata": {},
97+
"outputs": [],
98+
"source": [
99+
"gpas = np.array(gpas_as_list)"
100+
]
101+
},
102+
{
103+
"cell_type": "code",
104+
"execution_count": 7,
105+
"metadata": {},
106+
"outputs": [],
107+
"source": [
108+
"?gpas"
109+
]
110+
},
111+
{
112+
"cell_type": "code",
113+
"execution_count": 8,
114+
"metadata": {},
115+
"outputs": [
116+
{
117+
"data": {
118+
"text/plain": [
119+
"dtype('float64')"
120+
]
121+
},
122+
"execution_count": 8,
123+
"metadata": {},
124+
"output_type": "execute_result"
125+
}
126+
],
127+
"source": [
128+
"gpas.dtype"
129+
]
130+
},
131+
{
132+
"cell_type": "code",
133+
"execution_count": 9,
134+
"metadata": {},
135+
"outputs": [
136+
{
137+
"data": {
138+
"text/plain": [
139+
"8"
140+
]
141+
},
142+
"execution_count": 9,
143+
"metadata": {},
144+
"output_type": "execute_result"
145+
}
146+
],
147+
"source": [
148+
"gpas.itemsize"
149+
]
150+
},
151+
{
152+
"cell_type": "code",
153+
"execution_count": 10,
154+
"metadata": {},
155+
"outputs": [
156+
{
157+
"data": {
158+
"text/plain": [
159+
"4"
160+
]
161+
},
162+
"execution_count": 10,
163+
"metadata": {},
164+
"output_type": "execute_result"
165+
}
166+
],
167+
"source": [
168+
"gpas.size"
169+
]
170+
},
171+
{
172+
"cell_type": "code",
173+
"execution_count": 11,
174+
"metadata": {},
175+
"outputs": [
176+
{
177+
"data": {
178+
"text/plain": [
179+
"4"
180+
]
181+
},
182+
"execution_count": 11,
183+
"metadata": {},
184+
"output_type": "execute_result"
185+
}
186+
],
187+
"source": [
188+
"len(gpas)"
189+
]
190+
},
191+
{
192+
"cell_type": "code",
193+
"execution_count": 12,
194+
"metadata": {},
195+
"outputs": [
196+
{
197+
"data": {
198+
"text/plain": [
199+
"32"
200+
]
201+
},
202+
"execution_count": 12,
203+
"metadata": {},
204+
"output_type": "execute_result"
205+
}
206+
],
207+
"source": [
208+
"gpas.nbytes"
209+
]
210+
},
32211
{
33212
"cell_type": "code",
34213
"execution_count": null,

0 commit comments

Comments
(0)

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