0

was wondering if anyone can help me understand why the error keeps coming up:

AttributeError Traceback (most recent call last) in "AttributeError: 'int' object has no attribute 'sum'"

final5UK.head(5)/UKyear['Mortality'].sum()

Code Mortality Code Proportion C546 38945 C546 ...% C367 37687 C367 ...% C436 27857 C436 ...% C357 24868 C357 ...% C34 17849 C34 ...% trying to divide above table by a total figure from before to gain a new table with the individual proportions in % for each of the 5 listed above.

Thanks

Nicolas Gervais
  • 33,817
  • 13
  • 115
  • 143
projecthunder
  • 21
  • 1
  • 3

1 Answers1

2

Try this:

(final5UK.head(5)/UKyear['Mortality']).sum()

You were calling .sum() on the second part, which is just an integer.

Nicolas Gervais
  • 33,817
  • 13
  • 115
  • 143
  • Thanks for the response. It is returning a total number instead of 5 separate numbers I was expecting in a new table. Any tips on how to modify to get 5 individual proportions instead of 1 total?Thanks – projecthunder Jan 17 '20 at 14:59
  • remove the sum? what are the 5 separate numbers meant to be? – Nicolas Gervais Jan 17 '20 at 15:02