Monday, November 17, 2025
HomeLanguagesNumpy string operations | startswith() function

Numpy string operations | startswith() function

 numpy.core.defchararray.startswith() function returns a boolean array which is True where the string element in starts with prefix, otherwise False.

Syntax : numpy.core.defchararray.startswith(arr, prefix, start = 0, end = None)

Parameters :

arr : [array-like of str or unicode]  Array-like of str.

prefix : [str] Input string.

start, end : [int, optional] With optional start, test beginning at that position. With optional end, stop comparing at that position.

Return : [ndarray] Return the array of booleans.

Code #1 :  

Python3




# Python program explaining 
# numpy.char.startswith() function 
  
# importing numpy as geek  
import numpy as geek 
  
arr = "neveropen - A computer science portal"
prefix = 'Geeks'
  
gfg = geek.char.startswith(arr, prefix, start = 0, end = None)
    
print (gfg)


Output :  

True

Code #2 :  

Python3




# Python program explaining 
# numpy.char.startswith() function 
  
# importing numpy as geek  
import numpy as geek 
  
arr = "neveropen - A computer science portal"
prefix = 'None'
  
gfg = geek.char.startswith(arr, prefix, start = 0, end = None)
    
print (gfg)


Output : 

False

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32402 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6769 POSTS0 COMMENTS
Nicole Veronica
11920 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11990 POSTS0 COMMENTS
Shaida Kate Naidoo
6897 POSTS0 COMMENTS
Ted Musemwa
7150 POSTS0 COMMENTS
Thapelo Manthata
6851 POSTS0 COMMENTS
Umr Jansen
6843 POSTS0 COMMENTS