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

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -