I'm trying to write two for loops that will return a score for different inputs, and create a new field with the new score. The first loop works fine but the second loop never returns the correct score.
import pandas as pd
d = {'a':['foo','bar'], 'b':[1,3]}
df = pd.DataFrame(d)
score1 = df.loc[df['a'] == 'foo']
score2 = df.loc[df['a'] == 'bar']
for i in score1['b']:
    if i < 3:
        score1['c'] = 0
    elif i <= 3 and i < 4:
        score1['c'] = 1
    elif i >= 4 and i < 5:
        score1['c'] = 2
    elif i >= 5 and i < 8:
        score1['c'] = 3
    elif i == 8:
        score1['c'] = 4
for j in score2['b']:
    if j < 2:
        score2['c'] = 0
    elif j <= 2 and i < 4:
        score2['c'] = 1
    elif j >= 4 and i < 6:
        score2['c'] = 2
    elif j >= 6 and i < 8:
        score2['c'] = 3
    elif j == 8:
        score2['c'] = 4
        
print(score1)
print(score2)
When I run script it returns the following:
print(score1)
     a  b  c
0  foo  1  0
print(score2)
     a  b
1  bar  3
Why doesn't score2 create the new field "c" or a score?
 
     
    