myawesomepkg 0.1.4__py3-none-any.whl → 0.1.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of myawesomepkg might be problematic. Click here for more details.

@@ -0,0 +1,350 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 2,
6
+ "id": "a48de104",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "import numpy as np"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 3,
16
+ "id": "2a44575b",
17
+ "metadata": {},
18
+ "outputs": [],
19
+ "source": [
20
+ "name = ['Alice', 'Bob', 'Cathy', 'Doug']\n",
21
+ "age = [25, 45, 37, 19]\n",
22
+ "weight = [55.0, 85.5, 68.0, 61.5]"
23
+ ]
24
+ },
25
+ {
26
+ "cell_type": "code",
27
+ "execution_count": 4,
28
+ "id": "98f8f978",
29
+ "metadata": {},
30
+ "outputs": [],
31
+ "source": [
32
+ "x = np.zeros(4, dtype=int)\n"
33
+ ]
34
+ },
35
+ {
36
+ "cell_type": "code",
37
+ "execution_count": 5,
38
+ "id": "62710353",
39
+ "metadata": {},
40
+ "outputs": [
41
+ {
42
+ "name": "stdout",
43
+ "output_type": "stream",
44
+ "text": [
45
+ "[('name', '<U10'), ('age', '<i4'), ('weight', '<f8')]\n"
46
+ ]
47
+ }
48
+ ],
49
+ "source": [
50
+ "# Use a compound data type for structured arrays\n",
51
+ "data = np.zeros(4, dtype={'names':('name', 'age', 'weight'), 'formats':('U10', 'i4', 'f8')})\n",
52
+ "print(data.dtype)"
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "code",
57
+ "execution_count": 6,
58
+ "id": "75429517",
59
+ "metadata": {},
60
+ "outputs": [
61
+ {
62
+ "name": "stdout",
63
+ "output_type": "stream",
64
+ "text": [
65
+ "[('Alice', 25, 55. ) ('Bob', 45, 85.5) ('Cathy', 37, 68. )\n",
66
+ " ('Doug', 19, 61.5)]\n"
67
+ ]
68
+ }
69
+ ],
70
+ "source": [
71
+ "data['name'] = name\n",
72
+ "data['age'] = age\n",
73
+ "data['weight'] = weight\n",
74
+ "print(data)\n"
75
+ ]
76
+ },
77
+ {
78
+ "cell_type": "code",
79
+ "execution_count": 7,
80
+ "id": "81014a71",
81
+ "metadata": {},
82
+ "outputs": [
83
+ {
84
+ "data": {
85
+ "text/plain": [
86
+ "array(['Alice', 'Bob', 'Cathy', 'Doug'], dtype='<U10')"
87
+ ]
88
+ },
89
+ "execution_count": 7,
90
+ "metadata": {},
91
+ "output_type": "execute_result"
92
+ }
93
+ ],
94
+ "source": [
95
+ "# Get all names\n",
96
+ "data['name']"
97
+ ]
98
+ },
99
+ {
100
+ "cell_type": "code",
101
+ "execution_count": 8,
102
+ "id": "4ab9cc78",
103
+ "metadata": {},
104
+ "outputs": [
105
+ {
106
+ "data": {
107
+ "text/plain": [
108
+ "('Alice', 25, 55.)"
109
+ ]
110
+ },
111
+ "execution_count": 8,
112
+ "metadata": {},
113
+ "output_type": "execute_result"
114
+ }
115
+ ],
116
+ "source": [
117
+ "# Get first row of data\n",
118
+ "data[0]\n"
119
+ ]
120
+ },
121
+ {
122
+ "cell_type": "code",
123
+ "execution_count": 9,
124
+ "id": "97e72108",
125
+ "metadata": {},
126
+ "outputs": [
127
+ {
128
+ "data": {
129
+ "text/plain": [
130
+ "'Doug'"
131
+ ]
132
+ },
133
+ "execution_count": 9,
134
+ "metadata": {},
135
+ "output_type": "execute_result"
136
+ }
137
+ ],
138
+ "source": [
139
+ "# Get the name from the last row\n",
140
+ "data[-1]['name']"
141
+ ]
142
+ },
143
+ {
144
+ "cell_type": "code",
145
+ "execution_count": 10,
146
+ "id": "f766b733",
147
+ "metadata": {},
148
+ "outputs": [
149
+ {
150
+ "data": {
151
+ "text/plain": [
152
+ "array(['Alice', 'Doug'], dtype='<U10')"
153
+ ]
154
+ },
155
+ "execution_count": 10,
156
+ "metadata": {},
157
+ "output_type": "execute_result"
158
+ }
159
+ ],
160
+ "source": [
161
+ "# Get names where age is under 30\n",
162
+ "data[data['age'] < 30]['name']"
163
+ ]
164
+ },
165
+ {
166
+ "cell_type": "code",
167
+ "execution_count": 11,
168
+ "id": "97755d62",
169
+ "metadata": {},
170
+ "outputs": [
171
+ {
172
+ "data": {
173
+ "text/plain": [
174
+ "dtype([('name', '<U10'), ('age', '<i4'), ('weight', '<f8')])"
175
+ ]
176
+ },
177
+ "execution_count": 11,
178
+ "metadata": {},
179
+ "output_type": "execute_result"
180
+ }
181
+ ],
182
+ "source": [
183
+ "#Creating Structured Arrays\n",
184
+ "np.dtype({'names':('name', 'age', 'weight'), 'formats':('U10', 'i4', 'f8')})\n"
185
+ ]
186
+ },
187
+ {
188
+ "cell_type": "code",
189
+ "execution_count": 12,
190
+ "id": "42dc0929",
191
+ "metadata": {},
192
+ "outputs": [
193
+ {
194
+ "data": {
195
+ "text/plain": [
196
+ "dtype([('name', 'S10'), ('age', '<i4'), ('weight', '<f8')])"
197
+ ]
198
+ },
199
+ "execution_count": 12,
200
+ "metadata": {},
201
+ "output_type": "execute_result"
202
+ }
203
+ ],
204
+ "source": [
205
+ "np.dtype([('name', 'S10'), ('age', 'i4'), ('weight', 'f8')])"
206
+ ]
207
+ },
208
+ {
209
+ "cell_type": "code",
210
+ "execution_count": 13,
211
+ "id": "49dba453",
212
+ "metadata": {},
213
+ "outputs": [
214
+ {
215
+ "data": {
216
+ "text/plain": [
217
+ "dtype([('f0', 'S10'), ('f1', '<i4'), ('f2', '<f8')])"
218
+ ]
219
+ },
220
+ "execution_count": 13,
221
+ "metadata": {},
222
+ "output_type": "execute_result"
223
+ }
224
+ ],
225
+ "source": [
226
+ "np.dtype('S10,i4,f8')\n"
227
+ ]
228
+ },
229
+ {
230
+ "cell_type": "code",
231
+ "execution_count": 14,
232
+ "id": "322c3d0b",
233
+ "metadata": {},
234
+ "outputs": [
235
+ {
236
+ "name": "stdout",
237
+ "output_type": "stream",
238
+ "text": [
239
+ "(0, [[0., 0., 0.], [0., 0., 0.], [0., 0., 0.]])\n",
240
+ "[[0. 0. 0.]\n",
241
+ " [0. 0. 0.]\n",
242
+ " [0. 0. 0.]]\n"
243
+ ]
244
+ }
245
+ ],
246
+ "source": [
247
+ "#More Advanced Compound Types\n",
248
+ "tp = np.dtype([('id', 'i8'), ('mat', 'f8', (3, 3))])\n",
249
+ "X = np.zeros(1, dtype=tp)\n",
250
+ "print(X[0])\n",
251
+ "print(X['mat'][0])"
252
+ ]
253
+ },
254
+ {
255
+ "cell_type": "code",
256
+ "execution_count": 15,
257
+ "id": "5f12d9cd",
258
+ "metadata": {},
259
+ "outputs": [
260
+ {
261
+ "data": {
262
+ "text/plain": [
263
+ "array([25, 45, 37, 19])"
264
+ ]
265
+ },
266
+ "execution_count": 15,
267
+ "metadata": {},
268
+ "output_type": "execute_result"
269
+ }
270
+ ],
271
+ "source": [
272
+ "#RecordArrays: Structured Arrays with a Twist\n",
273
+ "data['age']\n"
274
+ ]
275
+ },
276
+ {
277
+ "cell_type": "code",
278
+ "execution_count": 16,
279
+ "id": "0c450acf",
280
+ "metadata": {},
281
+ "outputs": [
282
+ {
283
+ "data": {
284
+ "text/plain": [
285
+ "array([25, 45, 37, 19])"
286
+ ]
287
+ },
288
+ "execution_count": 16,
289
+ "metadata": {},
290
+ "output_type": "execute_result"
291
+ }
292
+ ],
293
+ "source": [
294
+ "data_rec = data.view(np.recarray)\n",
295
+ "data_rec.age"
296
+ ]
297
+ },
298
+ {
299
+ "cell_type": "code",
300
+ "execution_count": 17,
301
+ "id": "dfb95656",
302
+ "metadata": {},
303
+ "outputs": [
304
+ {
305
+ "name": "stdout",
306
+ "output_type": "stream",
307
+ "text": [
308
+ "141 ns ± 11 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n",
309
+ "2.31 µs ± 130 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)\n",
310
+ "3.74 µs ± 171 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)\n"
311
+ ]
312
+ }
313
+ ],
314
+ "source": [
315
+ "%timeit data['age']\n",
316
+ "%timeit data_rec['age']\n",
317
+ "%timeit data_rec.age"
318
+ ]
319
+ },
320
+ {
321
+ "cell_type": "code",
322
+ "execution_count": null,
323
+ "id": "7dfe30fe",
324
+ "metadata": {},
325
+ "outputs": [],
326
+ "source": []
327
+ }
328
+ ],
329
+ "metadata": {
330
+ "kernelspec": {
331
+ "display_name": "Python 3 (ipykernel)",
332
+ "language": "python",
333
+ "name": "python3"
334
+ },
335
+ "language_info": {
336
+ "codemirror_mode": {
337
+ "name": "ipython",
338
+ "version": 3
339
+ },
340
+ "file_extension": ".py",
341
+ "mimetype": "text/x-python",
342
+ "name": "python",
343
+ "nbconvert_exporter": "python",
344
+ "pygments_lexer": "ipython3",
345
+ "version": "3.9.13"
346
+ }
347
+ },
348
+ "nbformat": 4,
349
+ "nbformat_minor": 5
350
+ }