What is the numpy.char.startswith() function in Python?
Overview
The char.startswith() function in Python returns an array of Boolean values which is True where the string element in an input array of string starts with prefix. Otherwise, it returns False.
Syntax
char.startswith(a, prefix, start=0, end=None)
Syntax for the char.startswith() function
Parameters
The char.startswith()function takes the following parameter values:
a: An input array of strings.prefix: A string representing the prefix to be searched for.start,end: The optionalstartmeans that the test will begin at that position while an optionalendmeans stopping the comparison at that position.
Return value
The char.startswith() function returns an array of Boolean values with the same shape as the input array a.
Code
import numpy as np# creating input arraysmyarray1 = np.array(["Theo","Theophilus","The","Theology"])# printing the input arrayprint(myarray1)# implementing the char.startswith()# function on both arrays to see if they are equalprint(np.char.startswith(myarray1,"Theo",start=0,end=None))