Python | Numpy ndarray.imag()

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.

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output:

[ 2.  3.]

float64

Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output:

[ 0.78615138  0.89597748]

float64


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.