Reputation: 33
I want to change a numeric numpy array to char array using python,for example,
a = np.arange(25).reshape([5,5])
How to change array a to char array ?
Upvotes: 3
Views: 6458
Reputation: 2117
You can change the datatype of the numpy array by using astype
method. Try below example:
import numpy as np
a = np.arange(25).reshape([5,5])
a.dtype #check data type of array it should show int
new = a.astype(str) #change data type of array to string
new.dtype #Check the data type again it should show string
Upvotes: 9