Creating arrays#
Learning Objectives#
After working through this topic, you should be able to:
Create numpy arrays from Python lists
Create numpy arrays using numpy’s array creation functions
Reshape arrays
Repeat array elements
Materials#
Video:
Download the slides.
The numpy (documentation)
Quiz#
import numpy as np
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
b = np.array(a).reshape(3, 3)
print(b)
b.shape
c = b.repeat(3)
c.shape
[[1 2 3]
[4 5 6]
[7 8 9]]
(27,)