bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / char / array
function
numpy.char:array
source: build-install/usr/lib/python3.14/site-packages/numpy/_core/defchararray.py :1213
Signature
def array ( obj , itemsize = None , copy = True , unicode = None , order = None ) Summary
Create a chararray.
Extended Summary
Versus a NumPy array of dtype bytes_ or str_, 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.
chararray.endswith <numpy.char.chararray.endswith>) and infix operators (e.g.+, *, %)
Parameters
obj: array of str or unicode-likeitemsize: int, optionalitemsizeis the number of characters per scalar in the resulting array. Ifitemsizeis None, andobjis an object array or a Python list, theitemsizewill be automatically determined. Ifitemsizeis provided andobjis of type str or unicode, then theobjstring will be chunked intoitemsizepieces.copy: bool, optionalIf true (default), then the object is copied. Otherwise, a copy will only be made if
__array__returns a copy, if obj is a nested sequence, or if a copy is needed to satisfy any of the other requirements (itemsize, unicode,order, etc.).unicode: bool, optionalWhen true, the resulting chararray can contain Unicode characters, when false only 8-bit characters. If unicode is None and
objis one of the following:then the unicode setting of the output array will be automatically determined.
order: {'C', 'F', 'A'}, optionalSpecify 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). If order is 'A', then the returned array may be in any order (either C-, Fortran-contiguous, or even discontiguous).
Examples
import numpy as np char_array = np.char.array(['hello', 'world', 'numpy','array']) char_array✓
Aliases
-
numpy.char.array