numpy.char.asarray
-
numpy.char.asarray(obj, itemsize=None, unicode=None, order=None)
-
Convert the input to a
chararray
, copying the data only if necessary.Versus a regular NumPy array of type
str
orunicode
, 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.
str.endswith
) and infix operators (e.g.+
,*
,``%``)
- Parameters
-
-
objarray of str or unicode-like
-
itemsizeint, optional
-
itemsize
is the number of characters per scalar in the resulting array. Ifitemsize
is None, andobj
is an object array or a Python list, theitemsize
will be automatically determined. Ifitemsize
is provided andobj
is of type str or unicode, then theobj
string will be chunked intoitemsize
pieces. -
unicodebool, optional
-
When true, the resulting
chararray
can contain Unicode characters, when false only 8-bit characters. If unicode is None andobj
is one of the following:- a
chararray
, - an ndarray of type
str
or ‘unicode` - a Python str or unicode object,
then the unicode setting of the output array will be automatically determined.
- a
-
order{‘C’, ‘F’}, optional
-
Specify the order of the array. If order is ‘C’ (default), then the array will be in C-contiguous order (last-index varies the fastest). If order is ‘F’, then the returned array will be in Fortran-contiguous order (first-index varies the fastest).
-
© 2005–2020 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/1.19/reference/generated/numpy.char.asarray.html