Monday, May 18, 2026
HomeLanguagesNumpy str_len() function

Numpy str_len() function

numpy.char.str_len(arr) function is used for doing string operations in numpy. It returns the length of every string element wise.

Parameters:
arr : array_like of str or unicode.Input array.

Returns : [ndarray] Output Array of integer.

Code #1 :




# Python program explaining
# numpy.char.str_len() method 
  
# importing numpy 
import numpy as geek
  
# input array  
in_arr = geek.array(['neveropen forneveropen'])
print ("Input array : ", in_arr) 
  
# output array 
out_arr = geek.char.str_len(in_arr)
print ("Output array containing length: ", out_arr) 


Output:

Input array :  ['neveropen forneveropen']
Output array containing length:  [15]

 

Code #2 :




# Python program explaining
# numpy.char.str_len() method 
  
# importing numpy 
import numpy as geek
  
# input array 
in_arr = geek.array(['Numpy', 'Python', 'Pandas'])
print ("Input array : ", in_arr) 
  
  
# output array 
out_arr = geek.char.str_len(in_arr)
print ("Output array containing length: ", out_arr) 


Output:

Input array :  ['Numpy' 'Python' 'Pandas']
Output array containing length:  [5 6 6]
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32514 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6892 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12107 POSTS0 COMMENTS
Shaida Kate Naidoo
7016 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6975 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS