计数两个定时之间的表中的行数
我有这张桌子:
IdNum BeginDate Exitdate
-------------------------------------------------------------------------
123 2022-06-13 09:03 2022-06-13 22:12
633 2022-06-13 08:15 2022-06-13 13:09
389 2022-06-13 10:03 2022-06-13 18:12
665 2022-06-13 08:30 2022-06-13 10:12
我想在一天的每15分钟中获取数据,以了解该人(IDNUM)是否在此过程中。
例如:我想知道在18:00到18:15之间的过程中有多少个IDNUM。
根据上表,我应该得到:2
,因为在一天的15分钟内,只有IDNUM 123和IDNUM 389。
我可以编写一个函数或可以在上面接收该表的功能,然后返回一个带有96列的新表(对于一天的每15分钟),对于每行(IDNUM)时间?
示例:
IdNum BeginDate Exitdate 00:00 - 00:15 18:00 - 18:15 etc etc..
----------------------------------------------------------------------------------------------
123 2022-06-13 09:03 2022-06-13 22:12 FALSE TRUE
633 2022-06-13 08:15 2022-06-13 13:09 FALSE FALSE
389 2022-06-13 10:03 2022-06-13 18:12 FALSE TRUE
665 2022-06-13 08:30 2022-06-13 10:12 FALSE FALSE
接收3个变量的函数更容易
或者也许编写一个 在那段时间之间)。
在Python上更容易做什么?有可能吗?您能帮我牵头还是在Python上做些更好的方法?我上面提出的第一个还是第二个?
I've got this table:
IdNum BeginDate Exitdate
-------------------------------------------------------------------------
123 2022-06-13 09:03 2022-06-13 22:12
633 2022-06-13 08:15 2022-06-13 13:09
389 2022-06-13 10:03 2022-06-13 18:12
665 2022-06-13 08:30 2022-06-13 10:12
I want to get data for each 15 min of the day to know if the person (IdNum) was in the process.
For example: I want to know how many IdNum were in the process between 18:00 and 18:15.
According to the table above I should get: 2
Because only IdNum 123 and IdNum 389 were in the process during that 15 minutes of the day.
Can I write a function or something that receive that table above and returns a new table with 96 new column(for each 15 min of the day) and for each row (IdNum) you get True of False if he were in the process during that time?
Example:
IdNum BeginDate Exitdate 00:00 - 00:15 18:00 - 18:15 etc etc..
----------------------------------------------------------------------------------------------
123 2022-06-13 09:03 2022-06-13 22:12 FALSE TRUE
633 2022-06-13 08:15 2022-06-13 13:09 FALSE FALSE
389 2022-06-13 10:03 2022-06-13 18:12 FALSE TRUE
665 2022-06-13 08:30 2022-06-13 10:12 FALSE FALSE
OR maybe it is easier to write a function that receives 3 variables:
a table, a start time (exmp: 18:00), end time (exmp: 18:15) and it returns: 2 (number of IdNum's that were present between those times).
what is easier to do on Python? is that possible? can you help me with a lead or something of what is the better way to do it on Python? The first one or the second one I presented above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我的解决方案,您将在员工在第一个示例中显示的员工在这里的时间内拥有一个具有ID和布尔值的数据框。
Here my solution, you will have a Dataframe with Id as idex and booleans for the hours where the employees were here like you've shown in your first example.