In [1]:
import numpy as np
In [7]:
array = np.arange(15)
shape = array.reshape(3, 5)
shape
Out[7]:
ndarray.shape: the dimension of the array
In [8]:
shape.shape
Out[8]:
ndarray.ndim: the number of axes (dimensions) of the array
In [9]:
shape.ndim
Out[9]:
In [12]:
np.array([2,3,4])
Out[12]:
In [11]:
np.array([(1.5,2,3), (4,5,6)])
Out[11]:
In [13]:
np.zeros( (3,4) )
Out[13]:
In [14]:
np.ones( (2,3,4), dtype=np.int16 )
Out[14]:
In [15]:
np.arange( 10, 30, 5 ) # a sequence of number: start, end, step
Out[15]:
In [17]:
np.arange( 0, 2, 0.3 ) # float
Out[17]:
In [16]:
np.linspace( 0, 2, 9 ) # 9 numbers from 0 to 2
Out[16]:
In [ ]: