方法一:利用 [pandas.DataFrame.count](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.count.html) 函数获取。
trade.select("*").toDF().count()["col"]
# 其中 col 为 SQL 查询返回的 DataFrame 任意一列的名字
# toDF() 前可以替换为任意 SQL 语句
方法二:
在 DolphinDB 中,上述 t2=t1.select("count(*)") 脚本执行结果将保存在名为 "count" 的列里。调用 t2.toDF().count 时,由于 pandas.DataFrame 存在同名的方法 count,因此返回结果不是 count 列的结果。建议给 count(*) 返回的结果列取别名。
t2 = t1.select("count(*) as cnt")
t2.toDF().cnt
该脚本返回一个 Series 类型的结果。若要获取标量,直接通过索引即可:
t2.toDF().cnt[0]
附:[DolphinDB Python API 使用教程](https://github.com/dolphindb/api_python3/blob/master/README_CN.md),以供参考。