Grouping with non-sequential index (datetime) [Pandas] [Python]
Try this:
If needed, reset the index (this should not be a date time)
datos_frecuencia.groupby(datos_frecuencia.index // 3).agg({&quot;tiempo&quot;:lambda x: x.head(3).min(),&quot;state&quot;:sum})

Output: