I want to truncate the float values within the numpy array, for .e.g.
2.34341232 --> 2.34
I read the post truncate floating point but its for one float. I don't want to run a loop on the numpy array, it will be quite expensive. Is there any inbuilt method within numpy which can do this easily? I do need output as a float not string.
np.around(numpy_array, num_decimals). For example:a = np.array([2.3434]), np.around(a, 2) --> produces array([2.34]). Is this what are you looking for?numpy.aroundornumpy.roundmethod.num = ((num*100)//1)/100this logic only works for positive values. For example to truncate negative value to one decimal ,x = -2.134then(-2.134*10//1)10gives-3, which is not an acceptable answer.!