Array Basics
import numpy as npCreate Arrays
np.array(
object,
dtype = None,
copy = True,
order = None,
subok = False,
ndmin = 0
)
"""
#pointer, dtype, shape, stride
#object:
array;
object exposing the array interface;
object whose __array__ returns an array
nested list
#dtype: data type
#copy: if this is a copy
"""
a = np.array([[1,2],[3,4]])
b = np.array([1+1.j,2+1.j],dtype = np.complex) # a complex array
# use function of coordinates to create an array from a given shape
np.fromfunction(lambda i, j: i == j, (3, 3), dtype=int)
array([[ True, False, False],
[False, True, False],
[False, False, True]])Properties
Special Arrays
Indexing, Slicing & Iterating
Arithmetic Operations
Reference
Last updated