擅长:python、mysql、java
<p>解决了。问题是KDB返回的数据是按DESC顺序<strong>排序的,这混淆了方法<code>last()</code>。在</p>
<p>解决方案是在查询中添加一个sort子句(在Q语言中,它带有一个<a href="http://www.kdbfaq.com/kdb-faq/what-is-qs-equivalent-to-sqls-order-by.html" rel="nofollow noreferrer">backtick followed by the keyword xasc</a>)</p>
<pre><code>df = conn.sync("`Date xasc select Date, Open, High, Low, Close from stocktable", pandas=True) \
.last("5M")
</code></pre>
<p>或者,对Pandas数据框中的数据进行排序。在</p>
^{pr2}$