06 Properties of narray objects
Create a one-dimensional array
a = np.array([1, 2, 3, 4])
Create a two-dimensional array
b = np.arange(4, 10)
b1 = np.random.randint(4, 10, size = (2, 3))
print(b1)
Create a three-dimensional array
c = np.random.randn(2, 3, 4)
print(c)
Dimensional attributes of ndim arrays (one-dimensional; two-dimensional; three-dimensional ...)
print('ndim', a.ndim, b.ndim, c.ndim)
shape attribute of shape array (two-dimensional; three rows; four columns) *
print('shape:', a.shape, b.shape, c.shape)
dtype data element data type (int, float, etc.) attributes
print('dtype:',a.shape, b.shape, c.shape)
The total number of size elements
print('size',a.size, b.size, c.size)
itemsize the bytes occupied by each element
print('itemsize',a.itemsize, b.itemsize, c.itemsize)