Provided the three columns, I am looking to remove all IDs that do not have an indicator of Y that is equal to or less than 28 DateDiff. The Datediff column is the number of days from an initial incident.
df = pd.DataFrame({'ID':[111, 111, 111, 112, 112, 112, 113, 114, 114, 115,
115],
'Indicator':['N', 'Y', 'N', 'N', 'N', 'N', 'N', 'Y',
'N', 'Y', 'N'],
'Dateddiff': [0, 10, 32, 0, 19, 37, 29, 0, 28, 30, 34]})
Input
ID Indicator Datediff
111 N 0
111 Y 10
111 N 32
112 N 0
112 N 19
112 N 37
113 N 29
114 Y 0
114 N 28
115 Y 30
115 N 34
Output
ID Indicator Datediff
111 N 0
111 Y 10
111 N 32
114 Y 0
114 N 28