I have the following data:
Positions, Department, Salaries
Teacher, 600101, $1000
Janitor, 600230, $500
Principle, 600154, $1500
Secretary, 600342, $750
Manager, 600411, $2000
Teacher, 600105, $1200
Secretary, 600311, $1000
Teacher, 600300, $4000
I am trying to add together all of the salaries for the departments starting with 6001xx, and then also add all the salaries for departments starting 6002xx - 6004xx.
I have this and it kind of works....
def get_salaries(desc)
lineAmount = df.loc[(df['Position'] == desc) & (df['Department'] < 600200) & (df['Department'] >= 600100)]['Salaries'].values[0]
return lineAmount
totalSalaries = 0
totalSalaries += get_salaries('Teacher")
print(totalSalaries)
This will return only return the first salary. If i take off the .values[0] then it will return the salaries for Teachers in the correct department but it returns all of them in one output with the index as well, and it will not add them together. I need to be able to add the $1,000 and $1,200 from the teachers salaries from departments starting with 6001xx, and I just cannot figure it out. Any help is appreciated.