I am trying to write a code that extracts the ID of the teacher who assigned the same mid_term score to their students but then gave different scores on their finals.
While I'm interested in identifying the case where mid_term scores were the same for different final_scores, I am not interested in the converse relation i.e., it doesn't matter to me if the same final_scores are given for different mid_term scores.
Input:
My input df
looks something like this: :
TUserId SUID mid_sum final_sum
115 201 7 1
115 309 7 2
209 245 10 2
209 398 10 2
209 510 10 3
302 423 8 1
302 456 8 1
412 189 6 1
412 191 7 1
Output:
In the output I am just looking for a way to have the following flags with the teacher IDs
TUserId Flag
115 inconsistent
209 inconsistent
302 consistent
412 consistent
OR
TUserId Flag
115 TRUE
209 TRUE
302 FALSE
412 FALSE
Requirements:
When the value of mid_sum is the same across different students (shown by SUID
) of the same teacher (shown by TUserId
), it puts inconsistent in an additional column. I'm mainly looking for extracting the teacher ID where such discrepancy appeared.
This is related to the following two posts but one of the solutions meet my requirements.
Rolling computation to identify mismatch between two columns and Finding if a value is within the range of other columns
Any help on this would be greatly appreciated.