numpy.strings.title — NumPy v2.6.dev0 Manual

strings.title(a)

[source]

#

Return element-wise title cased version of string or unicode.

Title case words start with uppercase characters, all remaining cased characters are lowercase.

Calls

str.title

element-wise.

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

Parameters:aarray-like, with StringDType, bytes_, or str_ dtypeInput array.

Returns:outndarrayOutput array of StringDType, bytes_ or str_ dtype, depending on input types

Examples

>>> importnumpyasnp>>> c=np.array(['a1b c','1b ca','b ca1','ca1b'],'S5');carray(['a1b c', '1b ca', 'b ca1', 'ca1b'], dtype='|S5')>>> np.strings.title(c)array(['A1B C', '1B Ca', 'B Ca1', 'Ca1B'], dtype='|S5')