numpy.defchararray.capitalize() in Python

numpy.core.defchararray.multiply(arr, n): Capitalizes the first letter of string element-wise.

Parameters:
arr : array-like or string.

Returns : Capitalized first letter of the string.

Code #1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python Program illustrating 
# numpy.char.capitalize() method 
import numpy as np 
  
arr1 = ['eAAAaeAAAa', 'ttttdsttttds', 'AAtAAt']
arr2 = ['11sf', 'sdsf2', '1111f2']
  
print ("arr1 : ", arr1)
print ("arr2 : ", arr2)
  
Print("\nArrays after using capitalize():")
print ("\narr1 : ", np.char.capitalize(arr1))
print ("arr2 : ", np.char.capitalize(arr2))

chevron_right


Output:

arr1 :  ['eAAAaeAAAa', 'ttttdsttttds', 'AAtAAt']
arr2 :  ['11sf', 'sdsf2', '1111f2']

Arrays after using capitalize():
arr1 :  ['Eaaaaeaaaa' 'Ttttdsttttds' 'Aataat']
arr2 :  ['11sf' 'Sdsf2' '1111f2']

 
Code #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python Program illustrating 
# numpy.char.capitalize() method 
import numpy as np 
  
arr1 = 'this is geeks '
arr2 = 'for geeks '
  
print ("arr1 : ", arr1)
print ("arr2 : ", arr2)
  
Print("\nArrays after using capitalize():")
print ("\narr1 : ", np.char.capitalize(arr1))
print ("arr2 : ", np.char.capitalize(arr2))

chevron_right


Output:

arr1 :  this is geeks 
arr2 :  for geeks 

Arrays after using capitalize():
arr1 :  This is geeks 
arr2 :  For geeks  


My Personal Notes arrow_drop_up

Aspire to Inspire before I expire

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.