NumPy ndarray.imag() Method | Get Imaginary Part in NumPy Array Last Updated : 05 Feb, 2024 Comments Improve Suggest changes Like Article Like Report The ndarray.imag() method returns the imaginary part of the complex number in the NumPy array. Note: Remember resulting data type for the imaginary value is 'float64'. Example Python3 # import the important module in python import numpy as np # make an array with numpy gfg = np.array([1 + 2j, 2 + 3j]) # applying ndarray.imag() method geeks = np.imag(gfg) print(geeks, end ='\n\n') print(np.imag(geeks).dtype) Output[ 2. 3.] float64 SyntaxSyntax: ndarray.imag() Return Array of imaginary values having dtype 'float64'How to Find Imaginary Values of Complex Number in NumPy ArrayTo find the imaginary values in the NumPy array we use ndarray.imag() function of the NumPy library in Python. Let us understand it better with an example: Example: Find Imaginary Values in NumPy Array Python3 # import the important module in python import numpy as np # make an array with numpy gfg = np.array([1 + 2j, 2 + 3j]) gfg = np.sqrt(gfg) # applying ndarray.imag() method geeks = np.imag(gfg) print(geeks, end ='\n\n') print(np.imag(geeks).dtype) Output[ 0.78615138 0.89597748] float64 Comment More infoAdvertise with us Next Article NumPy ndarray.imag() Method | Get Imaginary Part in NumPy Array J Jitender_1998 Follow Improve Article Tags : Python Python-numpy Python numpy-ndarray Practice Tags : python Similar Reads NumPy ndarray.size() Method | Get Number of Elements in NumPy Array The ndarray.size() method returns the number of elements in the NumPy array. It works the same as np.prod(a.shape), i.e., the product of the dimensions of the array. Example Python3 import numpy as np arr = np.zeros((3, 4, 2), dtype = np.complex128) gfg = arr.size print (gfg) Output : 24Syntax Synta 1 min read NumPy ndarray.transpose() Method | Find Transpose of the NumPy Array The ndarray.transpose() function returns a view of the array with axes transposed. For a 1-D array, this has no effect, as a transposed vector is simply the same vector.For a 2-D array, this is a standard matrix transpose.For an n-D array, if axes are given, their order indicates how the axes are pe 2 min read NumPy ndarray.__abs__() | Find Absolute Value of Elements in NumPy Array The ndarray.__abs__() method returns the absolute value of every element in the NumPy array. It is automatically invoked when we use Python's built-in method abs() on a NumPy array. Example Python3 import numpy as np gfg = np.array([1.45, 2.32, 3.98, 4.41, 5.55, 6.12]) print(gfg.__abs__()) Output[ 1 1 min read Python | Numpy numpy.ndarray.__mod__() With the help of Numpy numpy.ndarray.__mod__(), every element in an array is operated on binary operator i.e mod(%). Remember we can use any type of values in an array and value for mod is applied as the parameter in ndarray.__mod__(). Syntax: ndarray.__mod__($self, value, /) Return: self%value Exam 1 min read numpy.linalg.eig() Method in Python In NumPy we can compute the eigenvalues and right eigenvectors of a given square array with the help of numpy.linalg.eig(). It will take a square array as a parameter and it will return two values first one is eigenvalues of the array and second is the right eigenvectors of a given square array. Syn 1 min read Python | Numpy numpy.ndarray.__imul__() With the help of numpy.ndarray.__imul__() method, we can multiply a particular value that is provided as a parameter in the ndarray.__imul__() method. Value will be multiplied to every element in a numpy array. Syntax: ndarray.__imul__($self, value, /)Return: self*=value Example #1 : In this example 1 min read Extracting the real and imaginary parts of an NumPy array of complex numbers Numpy library gives us functions such as real() and imag() to find real and imaginary parts of a complex number. real() : To find real part of the complex number imag() : To find imaginary part of the complex number Example 1 : python3 # importing the module import numpy as np # creating a NumPy arr 2 min read Python | sympy.is_imaginary method With the help of sympy.is_imaginary method, we can check whether element is imaginary or not this method will return the boolean value i.e True or False. Syntax : sympy.is_imaginary Return : Return True if imaginary else False. Example #1 : In this example we can see that by using sympy.is_imaginary 1 min read NumPy indices() Method | Create Array of Indices The indices() method returns an array representing the indices of a grid. It computes an array where the subarrays contain index values 0, 1, ⦠varying only along the corresponding axis. Example Python3 import numpy as np gfg = np.indices((2, 3)) print (gfg) Output : [[[0 0 0] [1 1 1]] [[0 1 2] [0 1 2 min read Numpy MaskedArray.getdata() - Python numpy.ma.getdata() function is used return the data of a masked array as an ndarray. Return the data of arr as an ndarray if arr is a MaskedArray, else return arr as a ndarray or subclass if not. Syntax : numpy.ma.getdata(a, subok=True) Parameters : arr : [array_like] Input MaskedArray, alternativel 2 min read Like