我有一个 DATE 向量,如下所示:
我想每5天获取一次数据,像这样:
我可以在 python 中使用以下 srcipt 来做到这一点:
A = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 23, 13, 14, 15]
print(A[0::5])
[0, 5, 10, 15]
DolphinDB有没有类似的方法?
方法一:计算要获取的元素的索引。
dataVector = 2021.01.01..2021.02.28
dataVector[at(0..(size(dataVector)-1)%5==0)]
方法二:使用
cutPoints
功能。但是最后得到的值需要删除,因为上界是包含的。
cutPoints(dataVector, ceil(dataVector.size()\5))
方法三:设置一个柱状元组,用函数
cut
对其进行切片,仅2.00.9版本支持。
cut(v, 5).setColumnarTuple!()[0]