python - Pandas Row Date Conditional Filter Prior to Groupby - MAXIFS/MINIFS -
i trying maxifs style calculations in pandas i trying add column containing next (if exists) & last (if exists) flagged date each unique id sample table: (trying next flag & last flag columns) edit: form more generic case, if wanted perform function e.g ditinctcount on period <= row the idea able apply custom functions applied filtered subset each id = row id , date <= row date (i have created pandas compatible row functions way slow) table: id date flag next flag last flag flag2 uniqueflags 1 21-aug 0 nan 18-aug 1 1 20-aug 0 nan 18-aug 1 1 19-aug 0 nan 18-aug 1 1 18-aug 1 nan 18-aug 1 1 17-aug 0 18-aug 15-aug 1 1 16-aug 0 18-aug 15-aug 1 1 15-aug 1 18-aug 15-aug 1 1 14-aug 0...