Participer au site avec un Tip
Rechercher
 

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 :

Module « numpy.matlib »

Classe « chararray »

Informations générales

Héritage

builtins.object
    ndarray
        chararray

Définition

class chararray(ndarray):

Description [extrait de chararray.__doc__]

    chararray(shape, itemsize=1, unicode=False, buffer=None, offset=0,
              strides=None, order=None)

    Provides a convenient view on arrays of string and unicode values.

    .. note::
       The `chararray` class exists for backwards compatibility with
       Numarray, it is not recommended for new development. Starting from numpy
       1.4, if one needs arrays of strings, it is recommended to use arrays of
       `dtype` `object_`, `string_` or `unicode_`, and use the free functions
       in the `numpy.char` module for fast vectorized string operations.

    Versus a regular NumPy array of type `str` or `unicode`, this
    class adds the following functionality:

      1) values automatically have whitespace removed from the end
         when indexed

      2) comparison operators automatically remove whitespace from the
         end when comparing values

      3) vectorized string operations are provided as methods
         (e.g. `.endswith`) and infix operators (e.g. ``"+", "*", "%"``)

    chararrays should be created using `numpy.char.array` or
    `numpy.char.asarray`, rather than this constructor directly.

    This constructor creates the array, using `buffer` (with `offset`
    and `strides`) if it is not ``None``. If `buffer` is ``None``, then
    constructs a new array with `strides` in "C order", unless both
    ``len(shape) >= 2`` and ``order='F'``, in which case `strides`
    is in "Fortran order".

    Methods
    -------
    astype
    argsort
    copy
    count
    decode
    dump
    dumps
    encode
    endswith
    expandtabs
    fill
    find
    flatten
    getfield
    index
    isalnum
    isalpha
    isdecimal
    isdigit
    islower
    isnumeric
    isspace
    istitle
    isupper
    item
    join
    ljust
    lower
    lstrip
    nonzero
    put
    ravel
    repeat
    replace
    reshape
    resize
    rfind
    rindex
    rjust
    rsplit
    rstrip
    searchsorted
    setfield
    setflags
    sort
    split
    splitlines
    squeeze
    startswith
    strip
    swapaxes
    swapcase
    take
    title
    tofile
    tolist
    tostring
    translate
    transpose
    upper
    view
    zfill

    Parameters
    ----------
    shape : tuple
        Shape of the array.
    itemsize : int, optional
        Length of each array element, in number of characters. Default is 1.
    unicode : bool, optional
        Are the array elements of type unicode (True) or string (False).
        Default is False.
    buffer : object exposing the buffer interface or str, optional
        Memory address of the start of the array data.  Default is None,
        in which case a new array is created.
    offset : int, optional
        Fixed stride displacement from the beginning of an axis?
        Default is 0. Needs to be >=0.
    strides : array_like of ints, optional
        Strides for the array (see `ndarray.strides` for full description).
        Default is None.
    order : {'C', 'F'}, optional
        The order in which the array data is stored in memory: 'C' ->
        "row major" order (the default), 'F' -> "column major"
        (Fortran) order.

    Examples
    --------
    >>> charar = np.chararray((3, 3))
    >>> charar[:] = 'a'
    >>> charar
    chararray([[b'a', b'a', b'a'],
               [b'a', b'a', b'a'],
               [b'a', b'a', b'a']], dtype='|S1')

    >>> charar = np.chararray(charar.shape, itemsize=5)
    >>> charar[:] = 'abc'
    >>> charar
    chararray([[b'abc', b'abc', b'abc'],
               [b'abc', b'abc', b'abc'],
               [b'abc', b'abc', b'abc']], dtype='|S5')

    

Constructeur(s)

Signature du constructeur Description
__new__(subtype, shape, itemsize=1, unicode=False, buffer=None, offset=0, strides=None, order='C')

Liste des attributs statiques

Attributs statiques hérités de la classe ndarray

base, ctypes, data, dtype, flags, flat, imag, itemsize, nbytes, ndim, real, shape, size, strides, T

Liste des opérateurs

Signature de l'opérateur Description
__add__(self, other)
__eq__(self, other)
__ge__(self, other)
__getitem__(self, obj)
__gt__(self, other)
__le__(self, other)
__lt__(self, other)
__mod__(self, i)
__mul__(self, i)
__ne__(self, other)
__radd__(self, other)
__rmod__(self, other)
__rmul__(self, i)

Opérateurs hérités de la classe ndarray

__and__, __contains__, __delitem__, __floordiv__, __iadd__, __iand__, __ifloordiv__, __ilshift__, __imatmul__, __imod__, __imul__, __invert__, __ior__, __ipow__, __irshift__, __isub__, __itruediv__, __ixor__, __lshift__, __matmul__, __neg__, __or__, __pos__, __pow__, __rand__, __rfloordiv__, __rlshift__, __ror__, __rpow__, __rrshift__, __rshift__, __rsub__, __rtruediv__, __rxor__, __setitem__, __sub__, __truediv__, __xor__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__array_finalize__(self, obj)
argsort(self, axis=-1, kind=None, order=None)
capitalize(self)
center(self, width, fillchar=' ')
count(self, sub, start=0, end=None)
decode(self, encoding=None, errors=None)
encode(self, encoding=None, errors=None)
endswith(self, suffix, start=0, end=None)
expandtabs(self, tabsize=8)
find(self, sub, start=0, end=None)
index(self, sub, start=0, end=None)
isalnum(self)
isalpha(self)
isdecimal(self)
isdigit(self)
islower(self)
isnumeric(self)
isspace(self)
istitle(self)
isupper(self)
join(self, seq)
ljust(self, width, fillchar=' ')
lower(self)
lstrip(self, chars=None)
partition(self, sep)
replace(self, old, new, count=None)
rfind(self, sub, start=0, end=None)
rindex(self, sub, start=0, end=None)
rjust(self, width, fillchar=' ')
rpartition(self, sep)
rsplit(self, sep=None, maxsplit=None)
rstrip(self, chars=None)
split(self, sep=None, maxsplit=None)
splitlines(self, keepends=None)
startswith(self, prefix, start=0, end=None)
strip(self, chars=None)
swapcase(self)
title(self)
translate(self, table, deletechars=None)
upper(self)
zfill(self, width)

Méthodes héritées de la classe ndarray

__abs__, __array__, __array_function__, __array_prepare__, __array_ufunc__, __array_wrap__, __bool__, __complex__, __copy__, __deepcopy__, __divmod__, __float__, __format__, __index__, __init_subclass__, __int__, __iter__, __len__, __rdivmod__, __reduce__, __reduce_ex__, __repr__, __rmatmul__, __setstate__, __sizeof__, __str__, __subclasshook__, all, any, argmax, argmin, argpartition, astype, byteswap, choose, clip, compress, conj, conjugate, copy, cumprod, cumsum, diagonal, dot, dump, dumps, fill, flatten, getfield, item, itemset, max, mean, min, newbyteorder, nonzero, prod, ptp, put, ravel, repeat, reshape, resize, round, searchsorted, setfield, setflags, sort, squeeze, std, sum, swapaxes, take, tobytes, tofile, tolist, tostring, trace, transpose, var, view

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __hash__, __init_subclass__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__