Numpy Flashcards
1
Q
Creating Arrays
A
> > > a = np.array([1,2,3])
b = np.array([(1.5,2,3), (4,5,6)], dtype = float)
c = np.array([[(1.5,2,3), (4,5,6)],[(3,2,1), (4,5,6)]], dtype = float)
2
Q
Create an array of zeros
A
> > > np.zeros((3,4))
3
Q
Create an array of ones
A
> > > np.ones((2,3,4),dtype=np.int
16)
4
Q
Create an array of evenly spaced values
step value
A
> > > d = np.arange(10,25,5)
5
Q
#Array dimensions #Length of array #Number of array dimensions #Number of array elements #Data type of array elements #Name of data type #Convert an array to a different type
A
>>> a.shape >>> len(a) >>> b.ndim >>> e.size >>> b.dtype >>> b.dtype.name >>> b.astype(int)