如何对不规则的时间戳列表进行重新采样/降采样?

编程入门 行业动态 更新时间:2024-10-08 19:45:11
本文介绍了如何对不规则的时间戳列表进行重新采样/降采样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

一个简单的问题,但我找不到一个简单的答案.

SImple question but I haven't been able to find a simple answer.

我有一个数据列表,该列表以秒为单位计算事件发生的时间:

I have a list of data which counts the time in seconds that events occur:

[200.0 420.0 560.0 1100.0 1900.0 2700.0 3400.0 3900.0 4234.2 4800.0 etc..]

我想统计每小时(3600秒)发生了多少事件,并为这些计数创建一个新列表.

I want to count how many events occur each hour (3600 seconds) and create a new list of these counts.

我知道这称为下采样,但是我能找到的所有信息都与传统时间序列有关.

I understand this is called downsampling, but all the information I can find is related to traditional time series.

对于上面的示例,新列表如下所示:

For the example above the new list would look like:

[7 3 etc..]

任何帮助将不胜感激.

推荐答案

all_events = [ 200.0, 420.0, 560.0, 1100.0, 1900.0, 2700.0, 3400.0, 3900.0, 4234.2, 4800.0] def get_events_by_hour(all_events): return [ len([x for x in all_events if int(x/3600.0) == hour]) for hour in xrange(24) ] print get_events_by_hour(all_events)

请注意,all_events应该包含一天的事件.

Note that all_events should contain events for one day.

更多推荐

如何对不规则的时间戳列表进行重新采样/降采样?

本文发布于:2023-11-30 12:44:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1650014.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对不   规则   时间   列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!