numpy.char.expandtabs#

char.expandtabs(a, tabsize=8)[source]#

Return a copy of each string element where all tab characters are replaced by one or more spaces.

Calls str.expandtabs element-wise.

Return a copy of each string element where all tab characters are replaced by one or more spaces, depending on the current column and the given tabsize. The column number is reset to zero after each newline occurring in the string. This doesn’t understand other non-printing characters or escape sequences.

Parameters:
aarray_like, with np.bytes_ or np.str_ dtype

Input array

tabsizeint, optional

Replace tabs with tabsize number of spaces. If not given defaults to 8 spaces.

Returns:
outndarray

Output array of str or unicode, depending on input type

See also

str.expandtabs

Examples

>>> a = np.array(['         Hello   world'])  
>>> np.strings.expandtabs(a, tabsize=4)  
array(['        Hello   world'], dtype='<U21')