1.

Write a program for inserting space between characters of all elements in a NumPy array.

Answer»

Sample Solution:-

import numpy as np

# Create Sample NumPy Array
arr = np.array(['i', 'love', 'NumPy', 'AND', 'interviewbit'], dtype=str)

transformed_arr = np.char.join(" ", arr)

print("Transformed Array: ")
print(transformed_arr)

Output:

Transformed Array:
['i' 'l o v e' 'N u m P y' 'A N D' 'i n t e r v i e w b i t']


Discussion

No Comment Found