问题
loading a csv file with pandas which store numpy arrays and strings, results in empty fields for the numpy values.
As nicely explained here, I load the csv with a converter as the numpy values are converted into strings.
def converter(instr):
return np.fromstring(instr[1:-1],sep=' ')
myFile = pd.read_csv('./EMBEDDINGS_224.csv', converters={'Embedding':converter})
The result per row is just
[]
The original 'Embedding' entry looks like this.
[[0.58197206 2.53598 0. ... 0.6681144 0.08705447 2.4330063 ]]
All other entries are actually in string format, so that should be fine.
I tried also to load with dtype=np.float32 and np.float64. This resulted in an error:
ValueError: could not convert string to float: '[[0.58197206 2.53598
0. ... 0.6681144 0.08705447 2.4330063 ]]'
Thank you for your help, keep healthy.
来源:https://stackoverflow.com/questions/60960170/loading-a-csv-with-pandas-results-in-empty-fields-for-numpy-values-while-using-c