Given a Pandas Data Frame that looks like this
GROUP VALUE MASK 1 5 false 2 10 false 2 20 false 1 7 tr
use groupby, diff, 'MASK'
groupby
diff
'MASK'
pd.concat([df.VALUE, df.groupby('GROUP').VALUE.diff()], axis=1, keys=['VALUE', 'DIFF'])[df.MASK]