Friday, September 26, 2025
HomeLanguagesPython | Numpy ndarray.imag()

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.




# 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
neveropen = np.imag(gfg)
    
print(neveropen, end ='\n\n')
print(np.imag(neveropen).dtype)


Output:

[ 2.  3.]

float64

Example #2 :




# 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
neveropen = np.imag(gfg)
    
print(neveropen, end ='\n\n')
print(np.imag(neveropen).dtype)


Output:

[ 0.78615138  0.89597748]

float64
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32320 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6683 POSTS0 COMMENTS
Nicole Veronica
11854 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11910 POSTS0 COMMENTS
Shaida Kate Naidoo
6795 POSTS0 COMMENTS
Ted Musemwa
7071 POSTS0 COMMENTS
Thapelo Manthata
6755 POSTS0 COMMENTS
Umr Jansen
6762 POSTS0 COMMENTS