python - Read a csv with numpy array using pandas -
i have csv file 3 columns emotion, pixels, usage consisting of 35000 rows e.g. 0,70 23 45 178 455,training.
i used pandas.read_csv read csv file pd.read_csv(filename, dtype={'emotion':np.int32, 'pixels':np.int32, 'usage':str}).
when try above, says valueerror: invalid literal long() base 10: '70 23 45 178 455'? how read pixels columns numpy array?
please try below code instead -
df = pd.read_csv(filename, dtype={'emotion':np.int32, 'pixels':str, 'usage':str}) def makearray(text): return np.fromstring(text,sep=' ') df['pixels'] = df['pixels'].apply(makearray)
Comments
Post a Comment