Python | Numpy ndarray.real()
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 the important module in python import numpy as np # make an array with numpy gfg = np.array([1 + 2j, 2 + 3j]) # applying ndarray.real() method geeks = np.real(gfg) print(geeks, end ='\n\n') print(np.real(geeks).dtype) |
[ 1. 2.] '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.real() method geeks = np.real(gfg) print(geeks, end ='\n\n') print(np.real(geeks).dtype) |
[ 1.27201965 1.67414923] float64
Recommended Posts:
- Python | Numpy numpy.ndarray.__iadd__()
- Python | Numpy numpy.ndarray.__isub__()
- Python | Numpy numpy.ndarray.__imul__()
- Python | Numpy numpy.ndarray.__neg__()
- Python | Numpy numpy.ndarray.__divmod__()
- Python | Numpy numpy.ndarray.__lt__()
- Python | Numpy numpy.ndarray.__xor__()
- Python | Numpy numpy.ndarray.__ge__()
- Python | Numpy numpy.ndarray.__or__()
- Python | Numpy numpy.ndarray.__eq__()
- Python | Numpy numpy.ndarray.__mul__()
- Python | Numpy numpy.ndarray.__ne__()
- Python | Numpy numpy.ndarray.__and__()
- Python | Numpy numpy.ndarray.__invert__()
- Python | Numpy numpy.ndarray.__rshift__()
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.



