[英]Find current active connections given connection and disconnection times of a location
I have a dataframe that has connection date , disconnection date , rowID and RouterName .我有一个 dataframe 具有连接日期、断开日期、 rowID和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.我想在一个循环中找到当前活动的连接,该循环每分钟迭代一次(这可以更改为任何分钟),持续 24 小时。 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.我找不到使用 python pandas 从数据集计算的方法。
I'm going to make a few assumptions:我要做几个假设:
every device Id is unique and there are no collisions每个设备 ID 都是唯一的,没有冲突
you are looking only for devices which are currently connected您只寻找当前连接的设备
a connected device has a null disconnect_at连接的设备具有 null disconnect_at
active = df[df.disconnect_at < curr_timestamp] counts = active.groupby(“router_name”).agg({“device_id”:pd.Series.nunique}) active = df[df.disconnect_at < curr_timestamp] counts = active.groupby(“router_name”).agg({“device_id”:pd.Series.nunique})
Something like this should work像这样的东西应该工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.