Numbers with j
are complex numbers:
>>> 1j * 1j
(-1+0j)
You can extract real part and imaginary part using real
, imag
attributes:
>>> c = 1 + 2j
>>> c.real
1.0
>>> c.imag
2.0
To convert numpy array with complex numbers to array with float: same; use real
, imag
attributes.
>>> np.array([1+0j, 2+0j]).real
array([ 1., 2.])