[ Web Proxy ]
URL:
Viewing: https://numpy.org/doc/stable/reference/generated/../generated/numpy.strings.capitalize.html [Back]  [Original]

numpy.strings.capitalize — NumPy v2.5 Manual
Back to top
Search the docs ...:

numpy.strings.capitalize#

strings.capitalize(a)[source]#

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

Calls str.capitalize element-wise.

For byte strings, this method is locale-dependent.

Parameters:
aarray-like, with StringDType, bytes_, or str_ dtype

Input array of strings to capitalize.

Returns:
outndarray

Output array of StringDType, bytes_ or str_ dtype, depending on input types

See also

str.capitalize

Examples

Try it in your browser!
>>> import numpy as np
>>> c = np.array(['a1b2','1b2a','b2a1','2a1b'],'S4'); c
array(['a1b2', '1b2a', 'b2a1', '2a1b'],
    dtype='|S4')
>>> np.strings.capitalize(c)
array(['A1b2', '1b2a', 'B2a1', '2a1b'],
    dtype='|S4')

Web Proxy Viewer  |  New URL  |  Original Page