可以用unpivot函数,比如: t = table(`a`b`c`d as productType, 4 5 1 2 as company1, 1 2 3 4 as company2, 3 23 4 5 as company3) unpivot(t, `productType, `company1`company2`company3)
回答于 2021-05-11 14:09
top n中的n须是常数,不能是变量。若要用变量,可用sql函数来实现: sql(select=sqlCol("*"), from=bn_1m_spot, limit=n).eval() 更多可参考https://github.com/dolphindb/...
回答于 2021-05-11 13:59
可以用context by和top来实现: select top 1 * from t1 context by sym csort price desc 也可以用atImax函数: select atImax(price,timestamp ) as time,atImax(price,price ) as price,atImax(price,qty ) as qty from t1 group by sym
回答于 2021-05-11 13:59
1.首先检查一下这个路径在dolphindb节点所在主机是否存在。脚本访问的是dolphindb服务器上文件,而不是GUI所在主机文件。2.若是docker部署,请检查一下这个路径是不是docker映射目录。 可以用exists函数检查一下是否存在这个文件。
回答于 2021-05-11 13:58
parseExpr之后的表达式,一般都使用在sql语句中,变量就是表。这个问题可以参考元编程教程第2.4节例子,1个向量对应表的1个列,传入一个表和一个表达式,动态生成一个sql语句执行,代码如下: def calculateExpress( formula, t){ return sql(sqlColAlias(parseExpr(formula), "value"), t).eval().value } t=table(...
回答于 2021-05-11 13:55
还有2种方法如下: update!(t, "feature_" + string(1001 .. 1030), loop(x->float(), 1..30)) update!(t, "feature_" + string(2001 .. 2030), loop(x->float(), 1..30)) t["feature_" + string(1001 .. 1030)]=loop(x->float(), 1..30) t["feature_" + string(2001 .. 2030)]=loop(x->float(), 1..30)
回答于 2021-05-11 13:54
时序数据库存在一些重复值是正常的,数据量极大的情况下,自增去重要付出很大的写入性能成本,建议在数据查询时做去重处理。可以参考使用isDuplicate, group by等方式
回答于 2021-05-11 13:53
可用DolphinD中的nunique函数实现,此函数可计算向量中非重复值的个数。 select nunique( x ) from t group by code;
回答于 2021-05-11 13:51