排序/组合相关数组
必须有某种算法可以使这比我正在做的事情更容易......
我有两个数组,每个数组有两列。两者中的一列是时间戳,另一列是测量值。
需要发生的是将其转换为单个数组:timestamp、measurement1、measurement2
问题是时间戳通常不会完全匹配。一个数组可能在某个时间段内完全缺少某个值,或者时间戳可能有微小的偏差(微小到可以将两个测量值分配给同一时间戳)。
是否有一些众所周知的方法来进行这种模糊合并操作?一个简单的公共领域功能?
There must be some algorithm that will make this easier than what I'm doing...
What I have are two arrays, each with two columns. One column in both is a timestamp, and the other in both is a measurement.
What needs to happen is turn this into a single array of: timestamp, measurement1, measurement2
The problem is the timestamps often won't match up exactly. One array might be missing a value completely for a time period, or the timestamps might be off by an insignificant amount (insignificant enough that it would be OK to assign both measurements to the same timestamp).
Is there some well-known way of doing this fuzzy merge operation? A simple public domain function??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先问自己这些问题:数组的元素数量是否相同?您想如何组合具有相同时间戳的两个项目?您想如何组合具有不同时间戳的两个项目?
您可能必须自己编写算法。这样的事情很容易实现:
~
Start by asking yourself these questions: Do the arrays have the same number of elements? How do you want to combine two items with the same timestamp? How do you want to combine two items with different timestamp?
You will probably have to write the algorithm yourself. Something like this would be easy to implement:
~