Arash
Arash

Reputation: 21

Segmenting pandas dataframe

Here is my problem. I have a dataframe that includes timestamps for a sensor reading. I want to divide it to different segments based on the time difference between the readings. For instance the first 1100 readings happened in day 0, then another 2000 readings happened in day 1, another 2200 reading in day 2 and so on. There is clearly a time difference between reading 1100 and 1101 that you can say a new reading is started (say the timestamp difference is more than 1 second which is the sampling frequency). One way to separate these segments is to calculate the time difference between rows then loop over all the rows, however this is a very slow method. Is there any other method for this?

Upvotes: 2

Views: 161

Answers (1)

boozy
boozy

Reputation: 323

You can use time windowing. A good way is rolling

Upvotes: 1

Related Questions