Python | Numpy ndarray.real()
Last Updated :
08 Apr, 2019
With the help of Numpy ndarray.real()
method, we can find the real values in an imaginary expressions by just using ndarray.real()
method. Remember resulting data type for the real value is ‘float64’.
Syntax : ndarray.real()
Return : Array of Real values having dtype ‘float64’
Example #1 :
In this example we can see that we get the array of real values using ndarray.real()
method and we are also trying to print the dtype of those real values.
import numpy as np
gfg = np.array([ 1 + 2j , 2 + 3j ])
geeks = np.real(gfg)
print (geeks, end = '\n\n' )
print (np.real(geeks).dtype)
|
Output:
[ 1. 2.]
'float64'
Example #2 :
import numpy as np
gfg = np.array([ 1 + 2j , 2 + 3j ])
gfg = np.sqrt(gfg)
geeks = np.real(gfg)
print (geeks, end = '\n\n' )
print (np.real(geeks).dtype)
|
Output:
[ 1.27201965 1.67414923]
float64
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...