0

I have a dataframe of 80 columns whereby I am trying to get the sum of the columns from the start of the indicated column to the last column.

df_category['Final_Score'] = df_category.iloc[:,42:].sum(1)

However when I ran the code below I realize that the last column was not taken into calculation.

I have tried to use iloc[:, -38:-1] and iloc[:,-38:] but it didn't work as well

below is a subset and sample of the scoring which I am trying to do.

Actual Score is the result I am trying to get

DDM
  • 303
  • 4
  • 19
  • Please do not share image. Instead please share the dataframe in clear text. Please read [How to make good reproducible pandas example](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – Joe Ferndz Mar 15 '21 at 03:29
  • Please note that `.iloc[]` is primarily integer position based (from 0 to length-1 of the axis), but may also be used with a boolean array. – Joe Ferndz Mar 15 '21 at 03:31
  • https://stackoverflow.com/questions/56311638/how-how-iloc-1-works-can-any-one-explain-1-params – Joe Ferndz Mar 15 '21 at 03:32

0 Answers0