Reputation: 630
How would I be able to turn all float numpy arrays into strings arrays?
import numpy as np
floats = np.array([1,3.4,0.678,11.1])
Expected output:
np.array(['1','3.4','0.678','11.1'])
Upvotes: 0
Views: 81
Reputation: 677
The simplest way:
np.array([1,3.4,0.678,11.1]).astype(str)
output:
array(['1.0', '3.4', '0.678', '11.1'], dtype='<U32')
Upvotes: 2