Thursday, July 4, 2024
HomeLanguagesPythonPython | Numpy expandtabs() method

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(['Geeks\tFor\tGeeks'], 10)
  
print(gfg)


Output :

[‘Geeks For Geeks’]

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’]

Thapelo Manthata
I’m a desktop support specialist transitioning into a SharePoint developer role by day and Software Engineering student by night. My superpowers include customer service, coding, the Microsoft office 365 suite including SharePoint and power platform.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments