import pandas as pd
I have a dataframe:
df=pd.DataFrame({'cmplxnumbers':[1+1j,2-2j,3*(1+1j)]})
I need to get the imaginary parts of the numbers in the column.
I do it by:
df.cmplxnumbers.apply(lambda number: number.imag)
I get as a result:
0 1.0
1 -2.0
2 3.0
Name: cmplxnumbers, dtype: float64
Which is as expected.
Is there any quicker, more straightforward method, perhaps not involving the lambda
function?