英文:
How to extract values from a vector with a specified step in DolphinDB?
问题
DolphinDB提供任何生成自然数或日期的算术序列的函数或方法吗?
我还想从一个向量中提取具有指定步长的值。以下是Python中如何实现的示例:
x = [1,2,3,4,5,6,7]
print(x[::3])
//输出:[1, 4, 7]
我如何在DolphinDB中实现这个功能?
英文:
I have two quetions:
Does DolphinDB offer any functions or methods to generate an
arithmetic sequence of natural numbers or dates?
I also want to extract values from a vector with a specified step. Below is an example of how this is done in Python:
x = [1,2,3,4,5,6,7]
print(x[::3])
//output: [1, 4, 7]
How can I achieve this in DolphinDB?
答案1
得分: 1
第一个问题,尝试以下方法:
2020.01.01 + 12 * 0..10
第二个问题,您可以首先根据所需的步骤计算出索引,然后提取值:
a = 1..10
a[3 * til ceil(a.count() / 3)]
[1, 4, 7, 10]
英文:
For your first question, try the following method:
2020.01.01 + 12*0..10
For your second question, you can first calculate the indices based on the desired step before extracting the values:
a = 1..10
a[3*til ceil(a.count())]
[1,4,7,10]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论