Adarsh singh
Adarsh singh

Reputation: 135

Updating Score column based upon the other column of the same Data Frame

I am using this data set enter image description here and i need to update the value of the 'Score' columns if the 'like' of the User is less than the data['like'].mean() i am trying to iterate through Rows and updating it using this code:-

for index, row in data.iterrows():
    if row['like'] < data.like.mean():
        row['Score'] +=10

but nothing is happening, Scores are not getting updated according to users like value, any help will be appreciated

Upvotes: 2

Views: 73

Answers (1)

Chris Adams
Chris Adams

Reputation: 18647

Try:

df.loc[df['like'].lt(df['like'].mean()), 'Score'] += 10

Upvotes: 1

Related Questions