chararray(shape, itemsize=1, unicode=False, buffer=None, offset=0, strides=None, order=None)
The :None:None:`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 :None:None:`dtype`
:None:None:`object_`
, :None:None:`string_`
or :None:None:`unicode_`
, and use the free functions in the :None:None:`numpy.char`
module for fast vectorized string operations.
Versus a regular NumPy array of type :None:None:`str`
or :None:None:`unicode`
, this class adds the following functionality:
values automatically have whitespace removed from the end when indexed
comparison operators automatically remove whitespace from the end when comparing values
vectorized string operations are provided as methods (e.g.
:None:None:`.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 :None:None:`buffer`
(with :None:None:`offset`
and :None:None:`strides`
) if it is not None
. If :None:None:`buffer`
is None
, then constructs a new array with :None:None:`strides`
in "C order", unless both len(shape) >= 2
and order='F'
, in which case :None:None:`strides`
is in "Fortran order".
Shape of the array.
Length of each array element, in number of characters. Default is 1.
Are the array elements of type unicode (True) or string (False). Default is False.
Memory address of the start of the array data. Default is None, in which case a new array is created.
Fixed stride displacement from the beginning of an axis? Default is 0. Needs to be >=0.
Strides for the array (see :None:None:`ndarray.strides`
for full description). Default is None.
The order in which the array data is stored in memory: 'C' -> "row major" order (the default), 'F' -> "column major" (Fortran) order.
Provides a convenient view on arrays of string and unicode values.
>>> 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)See :
... charar[:] = 'abc'
... charar chararray([[b'abc', b'abc', b'abc'], [b'abc', b'abc', b'abc'], [b'abc', b'abc', b'abc']], dtype='|S5')
The following pages refer to to this document either explicitly or contain code examples using this.
numpy.char.array
numpy.char.asarray
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them