Python | Numpy ndarray.imag()

• Last Updated : 08 Apr, 2019

With the help of Numpy ndarray.imag() method, we can find the imaginary values in an imaginary expressions by just using ndarray.imag() method. Remember resulting data type for the imaginary value is ‘float64’.

Syntax : ndarray.imag()

Return : Array of imaginary values having dtype ‘float64’

Example #1 :
In this example we can see that we get the array of imaginary values using ndarray.imag() method and we are also trying to print the dtype of those imag values.

 # import the important module in pythonimport numpy as np          # make an array with numpygfg = np.array([1 + 2j, 2 + 3j])          # applying ndarray.imag() methodgeeks = np.imag(gfg)    print(geeks, end ='\n\n')print(np.imag(geeks).dtype)
Output:
[ 2.  3.]

float64

Example #2 :

 # import the important module in pythonimport numpy as np          # make an array with numpygfg = np.array([1 + 2j, 2 + 3j])gfg = np.sqrt(gfg)          # applying ndarray.imag() methodgeeks = np.imag(gfg)    print(geeks, end ='\n\n')print(np.imag(geeks).dtype)
Output:
[ 0.78615138  0.89597748]

float64
My Personal Notes arrow_drop_up