array_attributes.py
import numpy as np
x1 = np.random.randint(10, size=6) # One-dimensional array
x2 = np.random.randint(10, size=(3, 4)) # Two-dimensional array
x3 = np.random.randint(10, size=(3, 4, 5)) # Three-dimensional array
print("x3 ndim: ", x3.ndim) # 3
print("x3 shape:", x3.shape) # (3,4,5)
print("x3 size: ", x3.size) # 60
from numpy import nbytes
b = arange(24).reshape(2,12)
b.ndim #Gives number of dimensions
b.size #Gives number of elements
b.itemsize #Gives number of bytes for each element in arrays
b.nbytes #Gives total number of bytes
b = array([1.j+1, 2.j+3]) #j represents complex number
b.real #Gives real part of array
b.imag #Gives imaginary part of array
b.dtype
b = arange(4).reshape(2,2)
b.flat #Returns numpy.flatiter object
b.flat[2] #Way to get an element with flatitier object
b.flat = 7 #Overwriting values
b.flat[[1,3]] = 1 #Overwriting values