0

I am multiplying float value with numpy array but getting these message:

can't multiply sequence by non-int of type 'float'.

I have read data from csv file which contain image pixels in each row. I want to make a matrix of whole pixel column(each row has 2034 pixel values) and then multiply it with other matrices of float values. Is each pixel value in the row considered as the string and that causing the error? To show the error I have multiplied first row with 0.1 values it shows for a :[ '70 80 82 72 58 58 60 63 ....34' ]

df=pd.read_csv('C:/Python36(64bit)/programs/intern/fer2013.csv')

df=df.drop('Usage',axis=1)
train=df[:28709]
test= df[28709:30000]
train_x=train.drop('emotion',axis=1)
train_y=train['emotion']
test_x=test.drop('emotion',axis=1)
test_y=test['emotion']
a=np.array(train_x.iloc[0])
b=a*0.1
Karan Purohit
  • 459
  • 3
  • 8
  • 16
  • Possible duplicate of [Why do I get TypeError: can't multiply sequence by non-int of type 'float'?](https://stackoverflow.com/questions/485789/why-do-i-get-typeerror-cant-multiply-sequence-by-non-int-of-type-float) – ralf htp Jan 14 '18 at 13:06

1 Answers1

0

convert the string values in the dataframe to float :

Converting strings to floats in a DataFrame

( Why do I get TypeError: can't multiply sequence by non-int of type 'float'? )

ralf htp
  • 9,149
  • 4
  • 22
  • 34