问答交流

【代码报错】SQL函数抽取数据有误

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

关于SQL 函数抽取数据有误的问题。

代码

import dai
import pandas as pd


sql = f"""
select date , instrument ,sw2021_level2 , m_avg(turn,40) as turn_40avg , m_nanstd(daily_return,40) as volatility_40 , m_regr_slope(daily_return,return_000001SH,40) as bate_40
from cn_stock_prefactors
where st_status = 0 and suspended = 0
ORDER BY 'date'
"""
df = dai.query(sql,filters={'date':['2022-05-10','2022-11-01']}).df()

结果

问题

都是40天的窗口周期,但是出现结果的时间不一样, m_nanstd(daily_return,40) as volatility_40 第三天出数据, m_avg(turn,40) as turn_40avg第40天出数据,m_regr_slope(daily_return,return_000001SH,40) as bate_40第41天出数据。老师能说一下问题所在吗?

标签

数据分析
{link}