from string to flaot python numpy 1

from string to flaot python numpy

float_array = string_array.astype(np.float)

Here is what the above code is Doing:
1. We create a string array with the values ‘1.25’, ‘-9.6′, ’42’
2. We use the astype() method to convert the values to floats
3. We assign the new array to the variable float_array

Similar Posts