1
My dataframe is called f0219. The following command filters a column of this df called Typorubrica when the code is equal to 2; this filter is assigned to the variable f0219Teto; Then, another command groups the new dataframe created, f0219Teto, by Matricula and Nome, and sums the contents of the column "Value", assigning the result to the variable f0219somaTeto. Finally, Check if any salary exceeded the set ceiling. Are three commands to do this. They are working, and return exactly what I want. However, I would like to group these three commands into one. How can I do this?
f0219Teto = f0219[f0219.Tiporubrica == 2] # filtra por codigo igual a 2
f0219somaTeto = f0219Teto.groupby(['Matricula', 'Nome'])['Nome','Valor'].sum() # agrupa por matricula e soma
f0219somaTeto[f0219somaTeto.Valor>39200] # verifica se houve ganho acima do teto
Dataframe example I’m working on: https://i.stack.Imgur.com/Qlg8j.png
Could you put a small sample of the data to understand the structure? It doesn’t need to be exactly the same, but so that you can manipulate it.
– Octávio Santana
I changed the original question with the example dataframe.
– Rogér