numpy read .csv with complex number

后端 未结 4 1072
-上瘾入骨i
-上瘾入骨i 2021-01-07 03:43

stackoverflow,

I have a matrix containing complex numbers (ex. -2.2982235934153075E-11+2.1179547211742553E-9i) that I need to import to a numpy array. I\'ve been us

4条回答
  •  隐瞒了意图╮
    2021-01-07 04:11

    The way I ended up having to do this was to first replace('i', 'j') for all cells in the original .csv file and save the new, corrected file. Afterwards, reading the .csv with dtype=str caused errors in subsequent calculations, but it turns out you can parse the .csv with dtype=complex128, which solved all my problems. Thanks for the help on the conversion @Saullo-Castro

提交回复
热议问题