Signup/Sign In
LAST UPDATED: DECEMBER 8, 2020

NumPy istitle() function

In this tutorial, we will cover istitle() function of the char module in the Numpy library.

The istitle() function returns true for each data element of the given ndarray if the elements in the input ndarray is a title cased string and there is at least one cased character. Otherwise, this function will return false.

For example, Apple is title cased, but apple is not and APPLE is also not titled case.

This function calls str.istitle in an element-wise manner.

This function is locale-dependent for an 8-bit string.

Syntax of istitle():

The syntax required to use this function is as follows:

numpy.char.istitle(a)

The above syntax indicates that istitle() is a function of the char module and it takes a single parameter.

In the above syntax, the argument a represents the input array of strings on which this function will be applied.

Returned Values:

This function will return an output array of boolean values.

Example 1:

import numpy as np 

inp1 = np.array(['APPLE', 'Mango', 'guava']) 
print ("The input array: ", inp1) 
out1 = np.char.istitle(inp1) 
print ("The output array:", out1 ) 


The input array : ['APPLE' 'Mango' 'guava']
The output array : [False True False]

Example 2:

The code snippet is as follows where we will use istitle() function:

import numpy as np 

inp2 = "This Is An Input String"
print ("The input array : \n", inp2) 

out2 = np.char.istitle(inp2) 
print ("The output array :\n", out2 ) 


The input array :
This Is An Input String
The output array :
True

Summary

This tutorial was all about istitle() function of the Numpy library. We covered how it is used with its syntax and values returned by this function.



About the author:
Aspiring Software developer working as a content writer. I like computer related subjects like Computer Networks, Operating system, CAO, Database, and I am also learning Python.