简体   繁体   English

在给定位置的连接和断开时间的情况下查找当前活动连接

[英]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 具有连接日期断开日期rowIDRouterName 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:我要做几个假设:

  1. every device Id is unique and there are no collisions每个设备 ID 都是唯一的,没有冲突

  2. you are looking only for devices which are currently connected您只寻找当前连接的设备

  3. 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.

相关问题 SQLAlchemy 侦听连接/断开连接事件 - SQLAlchemy listen to connection/disconnection events 解析日志文件以查找最活跃的时间 - Parsing a log file to find most active times 如何查找给定位置附近的位置 - How to find locations near a given location Paho MQTT客户端连接可靠性(断开时重新连接) - Paho MQTT client connection reliability (reconnect on disconnection) PyTorch如何实现断开连接(连接和相应的渐变被屏蔽)? - PyTorch how to implement disconnection (connections and corresponding gradients are masked)? 给定进程名称后,查找活动的进程ID - Find Process ID active when process name is given 如何找到一个单词在给定字符串中连续重复的最大次数? - How to find the largest number of times a word is repeated consecutively in a given string? Pythonic 方法来查找具有最接近特定目录位置的给定名称的文件 - Pythonic way to find the file with a given name closest to a specific directory location 给定x by x字符网格,找到单词及其位置 - given x by x grid of characters, find word and its location 给定网格的某些节点,找到飞机在网格上的位置 - Find the location of an airplane on a grid given some nodes of the grid
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM