Open In App

join() function - NumPy

Last Updated : 27 Sep, 2025
Suggest changes
Share
Like Article
Like
Report

The numpy.char.join() function is used to insert a specified separator between every character of each string element in a NumPy array. It is useful for formatting strings or creating patterns from text data.

For Example: This example demonstrates joining mixed-case words with a space as a separator.

Python
import numpy as np arr = np.array(['HeLLo', 'WORLD']) res = np.char.join(' ', arr) print("Array:", arr) print("Result:", res) 

Output
Array: ['HeLLo' 'WORLD'] Result: ['H e L L o' 'W O R L D'] 

Syntax

numpy.char.join(sep, arr)

Parameters:

  • sep: str or array_like -> Separator(s) inserted between characters.
  • arr: array_like -> Input array of strings.

Return Value: ndarray -> Array with strings joined using the specified separator(s).

Examples

Example 1: This example joins characters of words using different separators for each string.

Python
import numpy as np arr = np.array(['Python', 'Numpy', 'Pandas']) sep = np.array(['-', '+', '*']) res = np.char.join(sep, arr) print("Array:", arr) print("Result:", res) 

Output
Array: ['Python' 'Numpy' 'Pandas'] Result: ['P-y-t-h-o-n' 'N+u+m+p+y' 'P*a*n*d*a*s'] 

Example 2: This example joins characters of numeric strings with a colon (:).

Python
import numpy as np arr = np.array(['123', '456']) res = np.char.join(':', arr) print("Array:", arr) print("Result:", res) 

Output
Array: ['123' '456'] Result: ['1:2:3' '4:5:6'] 

Example 3: This example shows how the same separator can be applied to an array of names.

Python
import numpy as np arr = np.array(['Eve', 'Matt', 'Jack']) res = np.char.join('|', arr) print("Array:", arr) print("Result:", res) 

Output
Array: ['Eve' 'Matt' 'Jack'] Result: ['E|v|e' 'M|a|t|t' 'J|a|c|k'] 

Explore