1
I have a f0519_grouped dataframe like the one in the image. " Unique Identification" is the code that identifies the employee of the others; "Code Item" identifies the payment; I also have the name of the employee and "Value" identifies the value, which can add or discount. Whenever the Heading Code is 352, there is a discount. If it is any other value, it must be added up. In the example of the figure, I need to add the codes that are not 352, ie 1058, 1080 or 1387 and subtract when the code of the heading is equal to 352. And the result I must compare is greater than 39000. In this case, I must make 3546222 + 1564.47 + 11820.84 - 9554.11 = 39293.32, which is the result I hope to obtain. And then compare if it is greater than 39000. I’m using Pandas and the code below, but I don’t know why it doesn’t add up or discount according to the rubrics. Follow the code. Thank you.
f0519_grouped['Valor']=(f0519_grouped['Valor'] - (f0519_grouped['Valor'].where(f0519_grouped['Código Rubrica']==352)).fillna(0))
f0519_grouped[f0519_grouped["Valor"]>39000]
I do not think it will work because it is not just one employee, but several. That is, below, the Unique Identification employee = 364, I have another Unique Identification 365, then, 366 and so on (the registrations repeat because they are several types of payment that the same employee receives, identified by the field "Heading Code).
– roger roger
@rogerroger I edited my answer
– Terry
Perfect! That’s just what I needed. Thank you so much!
– roger roger