问答交流

【平台使用】如何将DAI查询的数据导出为XLS表格?

由bqo4psj8创建,最终由small_q 被浏览 13 用户

老师,请问DAI查询出来的数据表太大,如何单独形成一个XLS表格,方便自己进行分析,谢谢

import dai

df = dai.query("""

SELECT

    date, instrument,

    IF(price_limit_status = 3,1,0) AS _zt,

    If(m_sum(_zt,10) = 1,1,0) AS _firstzt,

     open/m_lead(close,-1)-1 AS _jump,

     If(_jump > 0.04,1,0) AS _jumphigh,

     close/open-1 AS _positive,

     IF(_positive > 0.04,1,0) AS _bigpositive ,

     IF( _zt = 1 and _jumphigh = 1 and _bigpositive =  1 and  _firstzt = 1,1,0) AS judge,

     IF(judge = 1, m_lead(close,1)/close-1, 0) AS return1,

     IF(judge = 1, m_lead(high,1)/close-1, 0) AS returnhigh,

     IF(return1 < 0 and returnhigh > 0,1,0) AS tr,

     IF(return1 > 0,1,0) AS po,

     IF(returnhigh < 0,1,0) AS pp,

     IF(m_lead(open,1) < close and return1 > 0,1,0) AS 低开正收,

     IF(m_lead(open,1) < close and return1 < 0,1,0) AS 低开负收,

     IF(m_lead(open,1) > close, 1,0)  AS 正开

FROM cn_stock_prefactors ,

WHERE  list_days > 260

        and st_status = 0

        and list_sector < 3

         and is_risk_warning = 0

         and suspended = 0

         and line_price_limit = 0

QUALIFY   judge = 1

ORDER BY date,instrument""",

filters={"date": \["2024-04-01", "2024-04-30"\]},

).df()

df

标签

数据处理数据分析
评论
  • 你这个只有78行不大,可以df.to_csv(‘test.csv)保存成csv,然后下载到本地分析
  • 谢谢
{link}