借助Numpy ndarray.imag()
方法,我們可以通過使用一個虛構表達式來找到虛構值ndarray.imag()
方法。請記住,虛數值的結果數據類型為“ float64”。
用法: ndarray.imag()
返回: dtype為'float64'的虛數值數組
範例1:
在此示例中,我們可以看到,使用ndarray.imag()
方法,我們還嘗試打印這些imag值的dtype。
# 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)
輸出:
[ 2. 3.] float64
範例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
geeks = np.imag(gfg)
print(geeks, end ='\n\n')
print(np.imag(geeks).dtype)
輸出:
[ 0.78615138 0.89597748] float64
相關用法
- Python Numpy numpy.ndarray.__mod__()用法及代碼示例
- Python Numpy numpy.ndarray.__ge__()用法及代碼示例
- Python Numpy numpy.ndarray.__invert__()用法及代碼示例
- Python Numpy numpy.ndarray.__divmod__()用法及代碼示例
- Python Numpy numpy.ndarray.__eq__()用法及代碼示例
- Python Numpy numpy.ndarray.__pow__()用法及代碼示例
- Python Numpy numpy.ndarray.__rshift__()用法及代碼示例
- Python Numpy numpy.ndarray.__le__()用法及代碼示例
- Python Numpy numpy.ndarray.__lt__()用法及代碼示例
- Python Numpy numpy.ndarray.__gt__()用法及代碼示例
- Python Numpy numpy.ndarray.__truediv__()用法及代碼示例
- Python Numpy numpy.ndarray.__mul__()用法及代碼示例
- Python Numpy numpy.ndarray.__sub__()用法及代碼示例
- Python Numpy numpy.ndarray.__pos__()用法及代碼示例
- Python Numpy numpy.ndarray.__add__()用法及代碼示例
注:本文由純淨天空篩選整理自Jitender_1998大神的英文原創作品 Python | Numpy ndarray.imag()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。