An array object represents a multidimensional, homogeneous array of fixed-size items. An associated data-type object describes the format of each element in the array (its byte-order, how many bytes it occupies in memory, whether it is an integer or a floating point number, etc.).
Arrays should be constructed using array, zeros or empty (refer to the See Also section below). The parameters given here describe a low-level method for instantiating an array (ndarray(...)).
For more information, refer to the numpy module and examine the the methods and attributes of an array.
Parameters: | shape : tuple of ints
dtype : data type, optional
buffer : object exposing buffer interface, optional
offset : int, optional
strides : tuple of ints, optional
order : {‘C’, ‘F’}, optional
|
---|---|
Attributes: | T : ndarray
data : buffer
dtype : data type
flags : dict
flat : ndarray
imag : ndarray
real : ndarray
size : int
itemsize : int
nbytes : int
shape : tuple of ints
strides : tuple of ints
ctypes : ctypes object
base : ndarray
|
See also
Notes
There are two modes of creating an array using __new__:
No __init__ method is needed because the array is fully initialized after the __new__ method.
Examples
These examples illustrate the low-level ndarray constructor. Refer to the See Also section for easier ways of constructing an ndarray.
First mode, buffer is None:
>>> np.ndarray(shape=(2,2), dtype=float, order='F')
array([[ -1.13698227e+002, 4.25087011e-303],
[ 2.88528414e-306, 3.27025015e-309]])
Second mode:
>>> np.ndarray((2,), buffer=np.array([1,2,3]),
... offset=np.int_().itemsize,
... dtype=int) # offset = 1*itemsize, i.e. skip first element
array([2, 3])