Python Forum
Give visit number ( or counter) within the same time frame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Give visit number ( or counter) within the same time frame
#1
Hi all

Thanks in advance for your help.

I have this below dataset.

Output:
Visitor ID Visit time AAA 27/06/2022 10:00:00 AAA 27/06/2022 10:05:21 AAA 27/06/2022 10:32:01 AAA 27/06/2022 13:04:01 AAA 28/06/2022 13:05:01 BBB 27/06/2022 11:00:00 BBB 27/06/2022 11:24:00 BBB 29/06/2022 11:24:00
I need for each visitor ID, assign a same visit number if the visit times ares in a 30min windows.
The result below would be

Output:
Visitor ID Visit time Visit number AAA 27/06/2022 10:00:00 1 AAA 27/06/2022 10:05:21 1 (same id than before as this time visitis less than 30min than the visit before) AAA 27/06/2022 10:32:01 1 (same id than before as this time visitis less than 30min than the visit before) AAA 27/06/2022 13:04:01 2 (as the difference btw this time visit and preivous visit is more than 30min) AAA 28/06/2022 13:05:01 2 (same id than before as this time visitis less than 30min than the visit before) BBB 27/06/2022 11:00:00 1 BBB 27/06/2022 11:34:00 2 (as the difference btw this time visit and preivous visit is more than 30min) BBB 29/06/2022 11:36:00 2 (same id than before as this time visitis less than 30min than the visit before)
Could you please tell me how I can do this in Python ? Or what logic I could use ?
Again, thanks a lot
B.
Reply
#2
what have you tried so far?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Give a number for Variable quest 2 906 Jan-31-2022, 08:35 AM
Last Post: ibreeden
  Filtering a data frame according to number of occurences of an observation Menthix 1 1,344 May-31-2021, 10:50 PM
Last Post: supuflounder
  How to print n days back date at give time Mekala 1 1,366 Oct-10-2020, 03:35 AM
Last Post: bowlofred
  Create a sequential number (counter) and reset at each duplicate Mekala 0 1,169 Sep-20-2020, 05:02 AM
Last Post: Mekala
  How to verify the give number is valid Mekala 3 1,699 May-16-2020, 02:40 PM
Last Post: anbu23
  My code is taking longer time to give result rajeshwin 4 2,461 Feb-20-2019, 08:18 PM
Last Post: ichabod801
  time counter Muhammad 0 1,389 Jan-31-2019, 07:31 PM
Last Post: Muhammad
  time.time wont return a useable number Nyscersul 4 2,257 Nov-15-2018, 03:08 PM
Last Post: Nyscersul
  How give an for loop an maximum number, help pleace ? JamieVanCadsand 3 2,797 Aug-09-2017, 08:15 AM
Last Post: JamieVanCadsand
  Button Presses in Certain Time Frame MsCheeseyPuff 3 3,217 Jun-30-2017, 08:39 PM
Last Post: MsCheeseyPuff

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020