... | ... | @@ -68,10 +68,44 @@ We can only scratch the surface during a one (1) hour workshop. |
|
|
|
|
|
The first few examples will be short and focus on arrays and statistics. These
|
|
|
examples are inspired by [*Coffee Break NumPy* by Christian
|
|
|
Mayer](https://www.amazon.com/Coffee-Break-NumPy-Science-Mastery/dp/1076932614)
|
|
|
Mayer](https://www.amazon.com/Coffee-Break-NumPy-Science-Mastery/dp/1076932614).
|
|
|
|
|
|
**Creating Arrays**
|
|
|
|
|
|
```Python
|
|
|
array_size = 8
|
|
|
zeroes_array = np.zeros(array_size)
|
|
|
print(zeroes_array)
|
|
|
print()
|
|
|
```
|
|
|
|
|
|
```Python
|
|
|
array_size = 12
|
|
|
ones_array = np.ones(array_size)
|
|
|
print(ones_array)
|
|
|
print()
|
|
|
```
|
|
|
|
|
|
```Python
|
|
|
# Contents are "whatever happens to be in memory"
|
|
|
array_size = 16
|
|
|
unitialized_array = np.empty(array_size)
|
|
|
print(unitialized_array)
|
|
|
print()
|
|
|
# Create two NumPy arrays from Python lists
|
|
|
python_list = [2, 4, 8, 16, 32, 64]
|
|
|
np_array = np.array(python_list)
|
|
|
print(np_array)
|
|
|
print()
|
|
|
```
|
|
|
|
|
|
```Python
|
|
|
python_list = [2., 4., 8., 16., 32., 64.]
|
|
|
np_array = np.array(python_list)
|
|
|
print(np_array)
|
|
|
print()
|
|
|
```
|
|
|
|
|
|
**I/O**
|
|
|
|
|
|
**Indexing**
|
... | ... | |