VOOZH about

URL: https://www.geeksforgeeks.org/python/how-to-insert-a-space-between-characters-of-all-the-elements-of-a-given-numpy-array/

⇱ How to Insert a Space between Characters of all the Elements of a given NumPy Array - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Insert a Space between Characters of all the Elements of a given NumPy Array

Last Updated : 27 Sep, 2025

NumPy provides function np.char.join(), which joins characters of a string using a specified separator.


Output
['H e l l o']

Syntax

np.char.join(sep, arr)

Parameters:

  • sep: separator to insert between characters.
  • arr: Input array of strings.

Return Value: Returns a new array where each string has its characters joined by the separator.

Examples

Example 1: In this example, we insert spaces between the characters of each string in the array.


Output
['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.


Output
['D-a-t-a' 'S-c-i-e-n-c-e']

Example 3: Here, we format numeric strings by adding spaces between digits.


Output
['1 2 3 4' '5 6 7 8']
Comment