【问题标题】:Fill Forward cupy / cudf向前填充cupy / cudf
【发布时间】:2020-10-04 17:35:47
【问题描述】:

应该可以用 cupy/cudf 执行填充吗?这个想法是执行一个施密特触发器函数,比如:

# pandas version
df = some_random_vector
on_off = (df>.3)*1 + (df<.3)*-1
on_off[on_off==0) = np.nan
on_off = on_off.fillna(method='ffill').fillna(0)

我正在尝试这个,但cupy没有积累ufunc:

def schmitt_trigger(x, th_lo, th_hi, initial = False):
    on_off = ((x >= th_hi)*1 + (x <= th_lo)*-1).astype(cp.int8)
    mask = (on_off==0)
    idx = cp.where(~mask, cp.arange(start=0, stop=mask.shape[0], step=1), 0)
    cp.maximum.accumulate(idx,axis=1, out=idx)
    out = on_off[cp.arange(idx.shape[0])[:,None], idx]
    return out

有什么想法吗? 谢谢!

【问题讨论】:

    标签: cupy cudf


    【解决方案1】:

    遗憾的是,RAPIDS 目前在cudf 中没有该功能,并且可能在 0.16 中也没有。 github中有功能请求。 https://github.com/rapidsai/cudf/issues/1361

    希望您能加入我们的请求,以便开发人员知道它的高度需求。

    至于施密特触发器,如果​​我有任何进展,我会研究它和你的代码并编辑这篇文章。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-06-20
      • 2020-08-03
      • 2021-10-08
      • 1970-01-01
      • 1970-01-01
      • 2016-10-20
      • 1970-01-01
      相关资源
      最近更新 更多