Pandas DataFrame从时间戳获得计数号

发布于 2025-01-19 14:17:36 字数 3797 浏览 3 评论 0原文

我有一个数据帧,其中包含来自传感器的记录,列为 ['time', 'X', 'Y']。我知道传感器以15赫兹(固定频率)扫描,但每次扫描之间的时间间隔并不一致。数据帧包含有效的 X 和每当传感器扫描检测到物体时,每次扫描的 Y 位置记录及其相关时间戳。这意味着每当传感器未检测到物体时,数据中就会存在时间间隙。现在我想从该数据集中提取扫描编号,无论扫描结果是否有效。

这是我的数据框的示例:

timeXY
2022-03-14 09:51:41.019000124
2022-03-14 09:51:41.101000125
2022-03-14 09:51:41.153000136
2022-03-14 09:51:41.225000156
2022-03-14 09:51:41.290000165
2022-03-14 09:51:41.360000165
2022-03-14 09:51:44.42400026-3
2022-03-14 09:51:44.48800028-4
2022-03-14 09:51:44.55700029-4

这是预期的结果:

时间XY扫描编号
2022-03 -14 09:51:41.0190001241
2022-03-14 09:51:41.1010001252
2022-03-14 09:51:41.1530001363
2022-03-14 09:51:41.2250001564
2022-03-14 09:51:41.2900001655
2022-03-14 09:51:41.3600001656
2022-03-14 09:51:43.42400026-337
2022-03-14 09:51:43.48800028-438
2022-03-14 09:51:43.55700029-439

I have a dataframe that contains recordings from a sensor with columns ['time', 'X', 'Y']. I know that the sensor scanned at 15 hz (fixed frequency), but the time interval between each scan is not consistent. The dataframe contains valid X & Y position recordings from each scan with their associated timestamp whenever the sensor scan detects an object. This means there are time gaps in the data whenever the sensor does not detect an object. Now I want to extract scan number from this data set irrespective of whether the scan resulted in a valid position or not.

Here is an example of my dataframe:

timeXY
2022-03-14 09:51:41.019000124
2022-03-14 09:51:41.101000125
2022-03-14 09:51:41.153000136
2022-03-14 09:51:41.225000156
2022-03-14 09:51:41.290000165
2022-03-14 09:51:41.360000165
2022-03-14 09:51:44.42400026-3
2022-03-14 09:51:44.48800028-4
2022-03-14 09:51:44.55700029-4

And here is the expected outcome:

timeXYScan-number
2022-03-14 09:51:41.0190001241
2022-03-14 09:51:41.1010001252
2022-03-14 09:51:41.1530001363
2022-03-14 09:51:41.2250001564
2022-03-14 09:51:41.2900001655
2022-03-14 09:51:41.3600001656
2022-03-14 09:51:43.42400026-337
2022-03-14 09:51:43.48800028-438
2022-03-14 09:51:43.55700029-439

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文