Home > Net >  creating a separate column where the score is inverse of the ranking in pandas
creating a separate column where the score is inverse of the ranking in pandas

Time:12-05

I am ranking a bunch of movies using pandas, from 1-100, and I was wondering how to create a separate column called score where the scores are inverse. for example:

rank score

  1. 100
  2. 99
  3. 98

all the way to

  1. 1

thank you!

CodePudding user response:

if already you have rank column with the values 1 to 100,

df['rank'] = range(1, 101)
df['score'] = range(len(df),0,-1)
  • Related