因子表达式问题求助
  18302000965 2025年10月12日 136 1

因子表达式

(if(((sum(high, 20) / 20) < high), (-1 * delta(high, 2)), 0))

问题

Can only compare identically-labeled Series objects

原因分析

(sum(high, 20) / 20) < high 比较时

SUM函数实现:series.groupby(level=‘symbol’).rolling(window=window, min_periods=1).sum().droplevel(0)

导致high序列与SUM计算后的返回序列顺序不一致

求助解法

最后一次编辑于 2025年10月12日 0

Cai

去function里检索“Can only compare identically-labeled Series objects”,看看这个报错的前提条件是什么,字面意思标签不一样,可能是长度不一样,用了rolling sum前几-1个window会是空的。

2025-12-02 22:22:18      回复

推荐阅读
  18302000965   2025年10月12日   137   0   1 Python