The Wayback Machine - https://web.archive.org/web/20231216160020/https://www.geeksforgeeks.org/numpy-string-operations-join-function/
Open In App
Related Articles

numpy string operations | join() function

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

numpy.core.defchararray.join(sep, arr) is another function for doing string operations in numpy. For each element in arr, it returns a copy of the string in which the string elements of array have been joined by separator.

Parameters:
sep : It joins elements with the string between them.
arr :Input array.

Returns : Output array of str or unicode with joined elements.

Code #1 :




# Python program explaining
# numpy.core.defchararray.join() method 
  
# importing numpy 
import numpy as geek
  
# input array 
in_arr = geek.array(['Python', 'Numpy', 'Pandas'])
print ("Input original array : ", in_arr) 
  
# creating the separator
sep = geek.array(['-', '+', '*'])
  
  
out_arr = geek.core.defchararray.join(sep, in_arr)
print ("Output joined array: ", out_arr) 


Output:

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

Don't miss your chance to ride the wave of the data revolution! Every industry is scaling new heights by tapping into the power of data. Sharpen your skills, become a part of the hottest trend in the 21st century.
Dive into the future of technology - explore the Complete Machine Learning and Data Science Program by GeeksforGeeks and stay ahead of the curve.

Last Updated : 05 Feb, 2019
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials