NumPy

Previous topic

numpy.char.mod

Next topic

numpy.char.center

This is documentation for an old release of NumPy (version 1.19). Read this page in the documentation of the latest stable release (version 2.2).

numpy.char.capitalize

numpy.char.capitalize(a)

Return a copy of a with only the first character of each element capitalized.

Calls str.capitalize element-wise.

For 8-bit strings, this method is locale-dependent.

Parameters
aarray_like of str or unicode

Input array of strings to capitalize.

Returns
outndarray

Output array of str or unicode, depending on input types

See also

str.capitalize

Examples

>>>
>>> c = np.array(['a1b2','1b2a','b2a1','2a1b'],'S4'); c
array(['a1b2', '1b2a', 'b2a1', '2a1b'],
    dtype='|S4')
>>> np.char.capitalize(c)
array(['A1b2', '1b2a', 'B2a1', '2a1b'],
    dtype='|S4')