Sample Data:
df1 = pd.DataFrame([
{'ID':'0001', 'Term':'Fall', 'Amount':1000},
{'ID':'0002', 'Term':'Fall', 'Amount':2000},
{'ID':'0001', 'Term':'Spring', 'Amount':50},
{'ID':'0002', 'Term':'Spring', 'Amount':50},
{'ID':'0001', 'Term':'Summer', 'Amount':200},
{'ID':'0002', 'Term':'Summer', 'Amount':200},
])
Output:
ID Term Amount
0 0001 Fall 1000
1 0002 Fall 2000
2 0001 Spring 50
3 0002 Spring 50
4 0001 Summer 200
5 0002 Summer 200
I want to update the Amount column for every row where the Term is 'Spring'. The Amount column should be set to the Amount value that corresponds to the same ID but for the 'Fall' term.
Any guidance would be appreciated.
Desired output:
ID Term Amount
0 0001 Fall 1000
1 0002 Fall 2000
2 0001 Spring 1000
3 0002 Spring 2000
4 0001 Summer 200
5 0002 Summer 200