![]() |
VOOZH | about |
NumPy provides function np.char.join(), which joins characters of a string using a specified separator.
['H e l l o']
np.char.join(sep, arr)
Parameters:
Return Value: Returns a new array where each string has its characters joined by the separator.
Example 1: In this example, we insert spaces between the characters of each string in the array.
['G e e k s' 'F o r' 'G e e k s']
Example 2: This example shows how we can use a different separator to join characters.
['D-a-t-a' 'S-c-i-e-n-c-e']
Example 3: Here, we format numeric strings by adding spaces between digits.
['1 2 3 4' '5 6 7 8']