d["p1"] = d["p"].rolling(5).apply(lambda x: pd.Series(x).corr(pd.Series(sorted(x))))
请问dolphindb有没有效果等价于这段pandas代码的数据处理方法呢?只对窗口中的数据进行排序,不要对整个列排序
使用自定义函数,参考如下:
select moving(x->corr(x, sort(x)), close, 5) from t context by code