Hour Site
01/08/2020 00:00 A
01/08/2020 00:00 B
01/08/2020 00:00 C
01/08/2020 00:00 D
01/08/2020 01:00 A
01/08/2020 01:00 B
01/08/2020 01:00 E
01/08/2020 01:00 F
01/08/2020 02:00 A
01/08/2020 02:00 E
01/08/2020 03:00 C
01/08/2020 03:00 G
…..
01/08/2020 04:00 x
01/08/2020 04:00 s
…..
01/08/2020 23:00 G
02/08/2020 00:00 G
I have a dataframe like above. I want to count how many times a site comes in consecutive hours & start and end timestamp. wheres in each hour there are multiple sites. For example site A appears in in 3 consecutive timestamp, then again in one timestamp. I want an output like below, or in more effective format.
Hour Site count period_start Period_end
01/08/2020 00:00 A 3 01/08/2020 00:00 01/08/2020 03:00
01/08/2020 00:00 B 2 01/08/2020 00:00 01/08/2020 01:00
01/08/2020 00:00 C 1 ….. …
01/08/2020 00:00 D 1 …. ….
01/08/2020 01:00 A 3 01/08/2020 00:00 01/08/2020 03:00
01/08/2020 01:00 B 2 …. ….
01/08/2020 01:00 E 2 …. ….
01/08/2020 01:00 F 1 …. ….
01/08/2020 02:00 A 3 01/08/2020 00:00 01/08/2020 03:00
01/08/2020 02:00 E 2 …. ….
01/08/2020 03:00 C 1 …. ….
01/08/2020 03:00 G 1 …. ….
….. …. ….
01/08/2020 04:00 x 1 01/08/2020 04:00 01/08/2020 04:00
01/08/2020 04:00 s 1 …. ….
…. ….
….. …. ….
…. ….
01/08/2020 23:00 G 2 …. ….
02/08/2020 00:00 G 2 …. ….
Thank you!