I saved with pandas a numpy array to a csv file:
df['Feature5'][i] = str(ri_RGBA.tolist())
df.to_csv(r'H:\test.csv')
The csv file has the following structure:
Feature1,Feature2,Feature3,Feature4,Labels,Feature5
13.37,33.09,-0.08,992.2,nass,"[[1, 160, 246, 255], … ,[1, 160, 246, 255]]"
26.37,33.03,-0.08,992.2,trocken,"[[110, 160, 246, 255], … ,[20, 160, 246, 255]]"
Now I'm trying to convert the string "[[1, 160, 246, 255], …" back to a numpy array:
data = df['Feature5'].apply(lambda x:
np.fromstring(
x.replace('\n','')
.replace('"','')
.replace('[','')
.replace(']','')
.replace(' ',' ')
.replace(' ',''), sep=','))
But print(data.dtypes)
still returns me type 'object'. What am I missing? Any ideas how I could make this work?
Help will be much appreciated.