NumPy | modf method
modf(~) method returns the fractional part and the integral part for each value in the input array.
Just to clarify:
For the number 3.5Fractional part: 0.5Integral part: 3
The input array.
Numpy array |
Instead of creating a new array, you can place the computed mean into the array specified by
Values that are flagged as False will be ignored, that is, their original value will be uninitialized. If you specified the out parameter, the behaviour is slightly different - the original value will be kept intact.
A tuple of Numpy arrays, with the first item being the fractional part and second being the integral part.
x = [1.5, 2.8, 4.1, 5]fractional_part, integral_part = np.modf(x)print(fractional_part) # [0.5, 0.8, 0.1, 0.]print(integral_part) # [ 1., 2., 4., 5.]