Python | Numpy expandtabs() method

With the help of numpy.char.expandtabs() method, we can expand the tab using numpy method in the single statement.

Syntax : numpy.char.expandtabs()

Return : Return the string array having expanded tabs.

Example #1 :

In this example we can see that by using numpy.char.expandtabs() method, we are able to get the expanded tabs by using numpy.




# import numpy
import numpy as np
  
# using numpy.char.expandtabs() method
gfg = np.char.expandtabs(['Beginner\tFor\tBeginner'], 10)
  
print(gfg)


Output :

[‘Beginner For Beginner’]

Example #2 :




# import numpy
import numpy as np
  
# using numpy.char.expandtabs() method
gfg = np.char.expandtabs(['G\tF\tG', 'Jitender\tKumar'], 20)
  
print(gfg)


Output :

[‘G F G’ ‘Jitender Kumar’]


Contact Us