builtins.object ndarray
class ndarray(builtins.object):
ndarray(shape, dtype=float, buffer=None, offset=0,
strides=None, order=None)
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, a floating point number,
or something else, etc.)
Arrays should be constructed using `array`, `zeros` or `empty` (refer
to the See Also section below). The parameters given here refer to
a low-level method (`ndarray(...)`) for instantiating an array.
For more information, refer to the `numpy` module and examine the
methods and attributes of an array.
Parameters
----------
(for the __new__ method; see Notes below)
shape : tuple of ints
Shape of created array.
dtype : data-type, optional
Any object that can be interpreted as a numpy data type.
buffer : object exposing buffer interface, optional
Used to fill the array with data.
offset : int, optional
Offset of array data in buffer.
strides : tuple of ints, optional
Strides of data in memory.
order : {'C', 'F'}, optional
Row-major (C-style) or column-major (Fortran-style) order.
Attributes
----------
T : ndarray
Transpose of the array.
data : buffer
The array's elements, in memory.
dtype : dtype object
Describes the format of the elements in the array.
flags : dict
Dictionary containing information related to memory use, e.g.,
'C_CONTIGUOUS', 'OWNDATA', 'WRITEABLE', etc.
flat : numpy.flatiter object
Flattened version of the array as an iterator. The iterator
allows assignments, e.g., ``x.flat = 3`` (See `ndarray.flat` for
assignment examples; TODO).
imag : ndarray
Imaginary part of the array.
real : ndarray
Real part of the array.
size : int
Number of elements in the array.
itemsize : int
The memory use of each array element in bytes.
nbytes : int
The total number of bytes required to store the array data,
i.e., ``itemsize * size``.
ndim : int
The array's number of dimensions.
shape : tuple of ints
Shape of the array.
strides : tuple of ints
The step-size required to move from one element to the next in
memory. For example, a contiguous ``(3, 4)`` array of type
``int16`` in C-order has strides ``(8, 2)``. This implies that
to move from element to element in memory requires jumps of 2 bytes.
To move from row-to-row, one needs to jump 8 bytes at a time
(``2 * 4``).
ctypes : ctypes object
Class containing properties of the array needed for interaction
with ctypes.
base : ndarray
If the array is a view into another array, that array is its `base`
(unless that array is also a view). The `base` array is where the
array data is actually stored.
See Also
--------
array : Construct an array.
zeros : Create an array, each element of which is zero.
empty : Create an array, but leave its allocated memory unchanged (i.e.,
it contains "garbage").
dtype : Create a data-type.
Notes
-----
There are two modes of creating an array using ``__new__``:
1. If `buffer` is None, then only `shape`, `dtype`, and `order`
are used.
2. If `buffer` is an object exposing the buffer interface, then
all keywords are interpreted.
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 above for easier ways of constructing an
ndarray.
First mode, `buffer` is None:
>>> np.ndarray(shape=(2,2), dtype=float, order='F')
array([[0.0e+000, 0.0e+000], # random
[ nan, 2.5e-323]])
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])
| Signature du constructeur | Description |
|---|---|
| __new__(*args, **kwargs) | Create and return a new object. See help(type) for accurate signature. [extrait de __new__.__doc__] |
| Nom de l'attribut | Valeur |
|---|---|
| base | <attribute 'base' of 'numpy.ndarray' objects> |
| ctypes | <attribute 'ctypes' of 'numpy.ndarray' objects> |
| data | <attribute 'data' of 'numpy.ndarray' objects> |
| dtype | <attribute 'dtype' of 'numpy.ndarray' objects> |
| flags | <attribute 'flags' of 'numpy.ndarray' objects> |
| flat | <attribute 'flat' of 'numpy.ndarray' objects> |
| imag | <attribute 'imag' of 'numpy.ndarray' objects> |
| itemsize | <attribute 'itemsize' of 'numpy.ndarray' objects> |
| nbytes | <attribute 'nbytes' of 'numpy.ndarray' objects> |
| ndim | <attribute 'ndim' of 'numpy.ndarray' objects> |
| real | <attribute 'real' of 'numpy.ndarray' objects> |
| shape | <attribute 'shape' of 'numpy.ndarray' objects> |
| size | <attribute 'size' of 'numpy.ndarray' objects> |
| strides | <attribute 'strides' of 'numpy.ndarray' objects> |
| T | <attribute 'T' of 'numpy.ndarray' objects> |
| Signature de l'opérateur | Description |
|---|---|
| __add__(self, value) | Return self+value. [extrait de __add__.__doc__] |
| __and__(self, value) | Return self&value. [extrait de __and__.__doc__] |
| __contains__(self, key) | Return key in self. [extrait de __contains__.__doc__] |
| __delitem__(self, key) | Delete self[key]. [extrait de __delitem__.__doc__] |
| __eq__(self, value) | Return self==value. [extrait de __eq__.__doc__] |
| __floordiv__(self, value) | Return self//value. [extrait de __floordiv__.__doc__] |
| __ge__(self, value) | Return self>=value. [extrait de __ge__.__doc__] |
| __getitem__(self, key) | Return self[key]. [extrait de __getitem__.__doc__] |
| __gt__(self, value) | Return self>value. [extrait de __gt__.__doc__] |
| __iadd__(self, value) | Return self+=value. [extrait de __iadd__.__doc__] |
| __iand__(self, value) | Return self&=value. [extrait de __iand__.__doc__] |
| __ifloordiv__(self, value) | Return self//=value. [extrait de __ifloordiv__.__doc__] |
| __ilshift__(self, value) | Return self<<=value. [extrait de __ilshift__.__doc__] |
| __imatmul__(self, value) | Return self@=value. [extrait de __imatmul__.__doc__] |
| __imod__(self, value) | Return self%=value. [extrait de __imod__.__doc__] |
| __imul__(self, value) | Return self*=value. [extrait de __imul__.__doc__] |
| __invert__(self) | ~self [extrait de __invert__.__doc__] |
| __ior__(self, value) | Return self|=value. [extrait de __ior__.__doc__] |
| __ipow__(self, value) | Return self**=value. [extrait de __ipow__.__doc__] |
| __irshift__(self, value) | Return self>>=value. [extrait de __irshift__.__doc__] |
| __isub__(self, value) | Return self-=value. [extrait de __isub__.__doc__] |
| __itruediv__(self, value) | Return self/=value. [extrait de __itruediv__.__doc__] |
| __ixor__(self, value) | Return self^=value. [extrait de __ixor__.__doc__] |
| __le__(self, value) | Return self<=value. [extrait de __le__.__doc__] |
| __lshift__(self, value) | Return self<<value. [extrait de __lshift__.__doc__] |
| __lt__(self, value) | Return self<value. [extrait de __lt__.__doc__] |
| __matmul__(self, value) | Return self@value. [extrait de __matmul__.__doc__] |
| __mod__(self, value) | Return self%value. [extrait de __mod__.__doc__] |
| __mul__(self, value) | Return self*value. [extrait de __mul__.__doc__] |
| __ne__(self, value) | Return self!=value. [extrait de __ne__.__doc__] |
| __neg__(self) | -self [extrait de __neg__.__doc__] |
| __or__(self, value) | Return self|value. [extrait de __or__.__doc__] |
| __pos__(self) | +self [extrait de __pos__.__doc__] |
| __pow__(self, value, mod=None) | Return pow(self, value, mod). [extrait de __pow__.__doc__] |
| __radd__(self, value) | Return value+self. [extrait de __radd__.__doc__] |
| __rand__(self, value) | Return value&self. [extrait de __rand__.__doc__] |
| __rfloordiv__(self, value) | Return value//self. [extrait de __rfloordiv__.__doc__] |
| __rlshift__(self, value) | Return value<<self. [extrait de __rlshift__.__doc__] |
| __rmod__(self, value) | Return value%self. [extrait de __rmod__.__doc__] |
| __rmul__(self, value) | Return value*self. [extrait de __rmul__.__doc__] |
| __ror__(self, value) | Return value|self. [extrait de __ror__.__doc__] |
| __rpow__(self, value, mod=None) | Return pow(value, self, mod). [extrait de __rpow__.__doc__] |
| __rrshift__(self, value) | Return value>>self. [extrait de __rrshift__.__doc__] |
| __rshift__(self, value) | Return self>>value. [extrait de __rshift__.__doc__] |
| __rsub__(self, value) | Return value-self. [extrait de __rsub__.__doc__] |
| __rtruediv__(self, value) | Return value/self. [extrait de __rtruediv__.__doc__] |
| __rxor__(self, value) | Return value^self. [extrait de __rxor__.__doc__] |
| __setitem__(self, key, value) | Set self[key] to value. [extrait de __setitem__.__doc__] |
| __sub__(self, value) | Return self-value. [extrait de __sub__.__doc__] |
| __truediv__(self, value) | Return self/value. [extrait de __truediv__.__doc__] |
| __xor__(self, value) | Return self^value. [extrait de __xor__.__doc__] |
| Signature de la méthode | Description |
|---|---|
| __abs__(self) | abs(self) [extrait de __abs__.__doc__] |
| __array__ | a.__array__([dtype], /) -> reference if type unchanged, copy otherwise. [extrait de __array__.__doc__] |
| __array_function__ | |
| __array_prepare__ | a.__array_prepare__(obj) -> Object of same type as ndarray object obj. [extrait de __array_prepare__.__doc__] |
| __array_ufunc__ | |
| __array_wrap__ | a.__array_wrap__(obj) -> Object of same type as ndarray object a. [extrait de __array_wrap__.__doc__] |
| __bool__(self) | self != 0 [extrait de __bool__.__doc__] |
| __complex__ | |
| __copy__ | a.__copy__() [extrait de __copy__.__doc__] |
| __deepcopy__ | a.__deepcopy__(memo, /) -> Deep copy of array. [extrait de __deepcopy__.__doc__] |
| __divmod__(self, value) | Return divmod(self, value). [extrait de __divmod__.__doc__] |
| __float__(self) | float(self) [extrait de __float__.__doc__] |
| __format__ | |
| __index__(self) | Return self converted to an integer, if self is suitable for use as an index into a list. [extrait de __index__.__doc__] |
| __int__(self) | int(self) [extrait de __int__.__doc__] |
| __iter__(self) | Implement iter(self). [extrait de __iter__.__doc__] |
| __len__(self) | Return len(self). [extrait de __len__.__doc__] |
| __rdivmod__(self, value) | Return divmod(value, self). [extrait de __rdivmod__.__doc__] |
| __reduce__ | a.__reduce__() [extrait de __reduce__.__doc__] |
| __reduce_ex__ | |
| __repr__(self) | Return repr(self). [extrait de __repr__.__doc__] |
| __rmatmul__(self, value) | Return value@self. [extrait de __rmatmul__.__doc__] |
| __setstate__ | a.__setstate__(state, /) [extrait de __setstate__.__doc__] |
| __sizeof__ | |
| __str__(self) | Return str(self). [extrait de __str__.__doc__] |
| all | a.all(axis=None, out=None, keepdims=False, *, where=True) [extrait de all.__doc__] |
| any | a.any(axis=None, out=None, keepdims=False, *, where=True) [extrait de any.__doc__] |
| argmax | a.argmax(axis=None, out=None) [extrait de argmax.__doc__] |
| argmin | a.argmin(axis=None, out=None) [extrait de argmin.__doc__] |
| argpartition | a.argpartition(kth, axis=-1, kind='introselect', order=None) [extrait de argpartition.__doc__] |
| argsort | a.argsort(axis=-1, kind=None, order=None) [extrait de argsort.__doc__] |
| astype | a.astype(dtype, order='K', casting='unsafe', subok=True, copy=True) [extrait de astype.__doc__] |
| byteswap | a.byteswap(inplace=False) [extrait de byteswap.__doc__] |
| choose | a.choose(choices, out=None, mode='raise') [extrait de choose.__doc__] |
| clip | a.clip(min=None, max=None, out=None, **kwargs) [extrait de clip.__doc__] |
| compress | a.compress(condition, axis=None, out=None) [extrait de compress.__doc__] |
| conj | a.conj() [extrait de conj.__doc__] |
| conjugate | a.conjugate() [extrait de conjugate.__doc__] |
| copy | a.copy(order='C') [extrait de copy.__doc__] |
| cumprod | a.cumprod(axis=None, dtype=None, out=None) [extrait de cumprod.__doc__] |
| cumsum | a.cumsum(axis=None, dtype=None, out=None) [extrait de cumsum.__doc__] |
| diagonal | a.diagonal(offset=0, axis1=0, axis2=1) [extrait de diagonal.__doc__] |
| dot | a.dot(b, out=None) [extrait de dot.__doc__] |
| dump | a.dump(file) [extrait de dump.__doc__] |
| dumps | a.dumps() [extrait de dumps.__doc__] |
| fill | a.fill(value) [extrait de fill.__doc__] |
| flatten | a.flatten(order='C') [extrait de flatten.__doc__] |
| getfield | a.getfield(dtype, offset=0) [extrait de getfield.__doc__] |
| item | a.item(*args) [extrait de item.__doc__] |
| itemset | a.itemset(*args) [extrait de itemset.__doc__] |
| max | a.max(axis=None, out=None, keepdims=False, initial=<no value>, where=True) [extrait de max.__doc__] |
| mean | a.mean(axis=None, dtype=None, out=None, keepdims=False, *, where=True) [extrait de mean.__doc__] |
| min | a.min(axis=None, out=None, keepdims=False, initial=<no value>, where=True) [extrait de min.__doc__] |
| newbyteorder | arr.newbyteorder(new_order='S', /) [extrait de newbyteorder.__doc__] |
| nonzero | a.nonzero() [extrait de nonzero.__doc__] |
| partition | a.partition(kth, axis=-1, kind='introselect', order=None) [extrait de partition.__doc__] |
| prod | a.prod(axis=None, dtype=None, out=None, keepdims=False, initial=1, where=True) [extrait de prod.__doc__] |
| ptp | a.ptp(axis=None, out=None, keepdims=False) [extrait de ptp.__doc__] |
| put | a.put(indices, values, mode='raise') [extrait de put.__doc__] |
| ravel | a.ravel([order]) [extrait de ravel.__doc__] |
| repeat | a.repeat(repeats, axis=None) [extrait de repeat.__doc__] |
| reshape | a.reshape(shape, order='C') [extrait de reshape.__doc__] |
| resize | a.resize(new_shape, refcheck=True) [extrait de resize.__doc__] |
| round | a.round(decimals=0, out=None) [extrait de round.__doc__] |
| searchsorted | a.searchsorted(v, side='left', sorter=None) [extrait de searchsorted.__doc__] |
| setfield | a.setfield(val, dtype, offset=0) [extrait de setfield.__doc__] |
| setflags | a.setflags(write=None, align=None, uic=None) [extrait de setflags.__doc__] |
| sort | a.sort(axis=-1, kind=None, order=None) [extrait de sort.__doc__] |
| squeeze | a.squeeze(axis=None) [extrait de squeeze.__doc__] |
| std | a.std(axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True) [extrait de std.__doc__] |
| sum | a.sum(axis=None, dtype=None, out=None, keepdims=False, initial=0, where=True) [extrait de sum.__doc__] |
| swapaxes | a.swapaxes(axis1, axis2) [extrait de swapaxes.__doc__] |
| take | a.take(indices, axis=None, out=None, mode='raise') [extrait de take.__doc__] |
| tobytes | a.tobytes(order='C') [extrait de tobytes.__doc__] |
| tofile | a.tofile(fid, sep="", format="%s") [extrait de tofile.__doc__] |
| tolist | a.tolist() [extrait de tolist.__doc__] |
| tostring | a.tostring(order='C') [extrait de tostring.__doc__] |
| trace | a.trace(offset=0, axis1=0, axis2=1, dtype=None, out=None) [extrait de trace.__doc__] |
| transpose | a.transpose(*axes) [extrait de transpose.__doc__] |
| var | a.var(axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True) [extrait de var.__doc__] |
| view | a.view([dtype][, type]) [extrait de view.__doc__] |
Améliorations / Corrections
Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.
Emplacement :
Description des améliorations :