How to insert a space between characters of all the elements of a given NumPy array? Last Updated : 29 Aug, 2020 Comments Improve Suggest changes Like Article Like Report In this article, we will discuss how to insert a space between the characters of all elements of a given array of string. Example: Suppose we have an array of string as follows: A = ["geeks", "for", "geeks"] then when we insert a space between the characters of all elements of the above array we get the following output. A = ["g e e k s", "f o r", "g e e k s"] To do this we will use np.char.join(). This method basically returns a string in which the individual characters are joined by separator character that is specified in the method. Here the separator character used is space. Syntax: np.char.join(sep, string) Parameters:sep: is any specified separator string: is any specified string. Example: Python3 # importing numpy as np import numpy as np # creating array of string x = np.array(["geeks", "for", "geeks"], dtype=np.str) print("Printing the Original Array:") print(x) # inserting space using np.char.join() r = np.char.join(" ", x) print("Printing the array after inserting space\ between the elements") print(r) Output: Printing the Original Array: ['geeks' 'for' 'geeks'] Printing the array after inserting spacebetween the elements ['g e e k s' 'f o r' 'g e e k s'] Comment More infoAdvertise with us Next Article How to insert a space between characters of all the elements of a given NumPy array? H hupphurr Follow Improve Article Tags : Python Python-numpy Python numpy-String Operation Practice Tags : python Similar Reads How to split the element of a given NumPy array with spaces? To split the elements of a given array with spaces we will use numpy.char.split(). It is a function for doing string operations in NumPy. It returns a list of the words in the string, using sep as the delimiter string for each element in arr. Parameters:arr : array_like of str or unicode.Input array 2 min read How to convert an array of indices to one-hot encoded NumPy array A very popular technique used in machine learning to transform categorical data into binary values of 0 and 1 is called the one-hot encoding technique. There are various circumstances when you need to use a one-hot encoded NumPy array rather than an array of indices, thus we can convert it using the 3 min read Repeat all the elements of a NumPy array of strings Let us see how to repeat all elements of the given array of string 3 times. Example : Input : ['Akash', 'Rohit', 'Ayush', 'Dhruv', 'Radhika'] Output : ['AkashAkashAkash', 'RohitRohitRohit', 'AyushAyushAyush', 'DhruvDhruvDhruv', 'RadhikaRadhikaRadhika'] We will be using the numpy.char.multiply(a, i) 2 min read How to rearrange columns of a 2D NumPy array using given index positions? In this article, we will learn how to rearrange columns of a given numpy array using given index positions. Here the columns are rearranged with the given indexes. For this, we can simply store the columns values in lists and arrange these according to the given index list but this approach is very 2 min read How to append a NumPy array to an empty array in Python In this article, we will cover how to append a NumPy array to an empty array in Python. Â Here, we will discuss 2 different methods to append into an empty NumPy array. Both of these methods differ slightly, as shown below: Append a NumPy array to an empty array using the appendExample 1 Here we are 2 min read Like