Find current active connections given connection and disconnection times of a location

176 Views Asked by At

I have a dataframe that has connection date, disconnection date, rowID and RouterName. I want to find the current active connections in a while loop which iterates every minutes(this can be changed to any minutes) for 24 hours. I am trying to calculate the count of people in the location from this dataset which i will later use for calculating the agents risk level of being infected with corona or any airborne infectious disease. I cant find a way to calculate this from dataset using python pandas. enter image description here

1

There are 1 best solutions below

2
On

I’m going to make a few assumptions:

  1. every device Id is unique and there are no collisions

  2. you are looking only for devices which are currently connected

  3. a connected device has a null disconnect_at

    active = df[df.disconnect_at < curr_timestamp] counts = active.groupby(“router_name”).agg({“device_id”:pd.Series.nunique})

Something like this should work