Reputation: 21343
I have a 2d numpy array of ints called M. I would like to convert all the ints to strings returning a 2d numpy array of the same shape. How can you do that?
I tried map(str, M)
but that doesn't work as it converts the individual rows into strings.
Upvotes: 0
Views: 128
Reputation: 41
If I have understood it right, you are trying to convert all integer elements in the array to a string. To do so, this should work:
np.char.mod('%d',M)
Upvotes: 1