I have a .excel file with complex number data and want it to convert to complex numpy array.
I tried the following code:
df=pd.read_excel(location, sheet_name='complex')
np_complex=df.to_numpy(dtype=complex)
It has worked previously, although nothing is changed (I think) but now it is raising the error
TypeError: must be real number, not str
In line np_complex=df.to_numpy(dtype=complex)
Can anyone suggest the change in code?
Your code is right. Try to rebuild then run. When I run this code it works fine my IDE. This is code Code and its result Result.