Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

NumPy: title() function

numpy.core.defchararray.title() function

The numpy.core.defchararray.title() function returns 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.

Version: 1.15.0

Syntax:

numpy.core.defchararray.title(a)

Parameter:

Name Description Required /
Optional
a: array_like, {str, unicode} Input array. Required

Return value:

out [ndarray] Output array of str or unicode, depending on input type.

Example-1: numpy.title() function

>>> import numpy as np
>>> x=np.array(['a1b c','1b ca','b ca1','ca1b'],'S5'); x
array([b'a1b c', b'1b ca', b'b ca1', b'ca1b'], dtype='|S5')
>>> np.char.title(x)
array([b'A1B C', b'1B Ca', b'B Ca1', b'Ca1B'], dtype='|S5')

Pictorial Presentation:

NumPy String operation: title() function

Example-2: numpy.title() function

>>> import numpy as np
>>> x = np.array('the quick brown fox');
>>> x
array('the quick brown fox', dtype='<U19')
>>> np.char.title(x)
array('The Quick Brown Fox', dtype='<U19')

Pictorial Presentation:

NumPy String operation: title() function

Python - NumPy Code Editor:

Previous: swapcase()
Next: translate()