numpy.ndarray.imag — NumPy v2.6.dev0 Manual

attribute

ndarray.imag

#

The imaginary part of the array.

Returns a view into the original array for complex arrays. For non-complex arrays, returns a zero array of the same dtype. For object arrays returns elementwise .imag or 0 if .imag is undefined.

Examples

>>> importnumpyasnp>>> x=np.sqrt([1+0j,0+1j])>>> x.imagarray([ 0. , 0.70710678])>>> x.imag.dtypedtype('float64')