Is there any tool in Pandas or other python package to facilitate the labeling of groups of varying number rows in a Pandas’ dataFrame? Here are more detail:
My dataFrame has a column of datetime.datetime objects used as the dataFrame index. The time is not evenly spaced and during a given amount of time, the number of rows varies.
In that dataFrame, I need to make a column that has a different label for each series of rows that span over a constant time span (12 seconds in my case).
For example, using examples with seconds
Time(s) | label
1 | 0
2 | 0
3 | 0
7 | 0
12 | 1
15 | 1
20 | 1
24 | 2
Etc…
I’m looking for an alternative as a brute-force loop. Algorithms somewhat related to that are labeling, segmenting, mapping but i'm not sure what to look for exactly. I was hoping there would be something exploiting python, Pandas and/or Numpy in a more efficient way since the number of rows is gonna be of the order of a hundred millions.
Thanks