numpy.modf()
functionThe Python library, NumPy
, has a method called modf()
. The numpy.modf()
method returns the fractional and integral parts of an input array, element-wise.
Note: A two-dimensional (2D) array can be created using a list of lists in Python.
numpy.modf(x1, x2, dtype=None, out=None)
x1
: This is an array-like parameter that represents the input data.dtype
: This is an optional parameter. It represents the return type of the array.out
: This is an optional parameter. It represents the alternative output array in which the result is to be placed.The numpy.modf()
method returns the fractional and integral parts of an input array, element-wise.
Note: If the specified number is negative, the fractional and integral parts are negative.
The following code shows how to use the numpy.modf()
method for two-dimensional (2D) arrays:
# import numpyimport numpy as np# create a 2D arraysx = np.array([[2,-0.6,5],[3.0,4,8.23]])# using modf()result = np.modf(x)print(result)
numpy
library.x
.np.modf()
with the parameter x
. This returns the fractional and integral parts of an input array element-wise. The result is stored in a new variable called result
.result
.