擅长:python、mysql、java
<p>我想不出一个解决方案可以完全满足您的需要,但是虽然它对我来说并不太简单,但它应该可以在不进行插值的情况下实现您想要的结果。每秒钟最多给出一个值(最左边):</p>
<pre><code># Assuming that t is sorted...
# Create all full seconds.
seconds = np.arange(int(t[0]), int(t[-1]) + 1)
# find the indexes for all
idx = np.searchsorted(t, seconds)
idx = np.unique(idx) # there might be duplicates if a second has no data in it.
</code></pre>
<p>对于您的例子,它给出了相同的结果,但是它通常允许更小或更大的差异(0到2秒之间的任何值)。。。在</p>