我试图乘以1j创建的熊猫系列,但随后得到一个 TypeError:
TypeError:不能将序列乘以'complex'类型的非整数
这是我试图做的:
import pandas as pd
d = {'real' : pd.Series(real_vals), #those are integers
'imag' : pd.Series(imag_vals)} #those are integers
df = pd.DataFrame(d)
df['imagj'] = df['imag'] * 1j #try to create new column
#I also tried:
df.loc[:,'imag'] *= -1j #try to multiply the same column
它们都不起作用。你能指出我吗?
我希望将df['imag']
列乘以1j。