Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas.DataFrame.sum(axis = 1) not working

Tags:

python

pandas

I'm trying to sum my dataframe across axis = 1 but for some reason its not working for me. I'm not entirely sure why its not working. Any help would be appreciated.

Original DataFrame:

enter image description here

Attempt at summing along axis = 1

enter image description here

like image 655
bugsyb Avatar asked Jul 11 '17 03:07

bugsyb


1 Answers

There is problem type of your data is not float but string.

So need cast to float by astype:

norm = data[colors.keys()].astype(float).sum(axis=1)
like image 179
jezrael Avatar answered Oct 22 '22 06:10

jezrael