mercredi 10 février 2021

Is there a easy way to detect when a reoccurring pattern starts and ends in a pandas timeseries?

I have a time series data of city bus. This is the data enter image description here

This is the Longitude vs the time graph. enter image description here

The bus at the beginning comes out from the depot and take some times to come to the daily route. When it comes there, then the repeating pattern occurs as the wheels on the bus go round and round all day long :)

This is for a day. Each day is different. Is there is a clever way to detect when the repeating pattern starts and ends from the time series? Visually, the bus comes at the daily route around 3:50 AM and ends at 10:25 PM.

What I did, I took rolling windows of 60 min and ploted.

route = day1['gps_0'].rolling(window='60T').max().plot()

enter image description here

The repeating pattern smooths out. Then I calculated max number of occurrences of the Longitude value which is 60.207. Then, from the main data, I located when was the first and last time 60.207 occurred at the data frame.

I know it is not the most clever way to do this. Wondering are there any other ways.

Aucun commentaire:

Enregistrer un commentaire