请求关于cut和cutpostion的用法例子

我最近在尝试利用ddb sql做动态因子选股,和证券的分类评分上。

我之前是使用 pd.cut 做tag标签,入库的方式来实现,主要是按照其价值进行等量的分类。但我想更近一步采用即时动态生成。

attachments-2022-06-dJBv1qun62a83c5a85164.jpg

xxx.loc[:, 'lv'] = pd.cut(xxx['value'], 3, labels=['low', 'mid', 'high'])


我找到了相关的cut和cutpostion的函数进行了阅读。

但我看不懂 ddb的cut和cutpostion的方式

请问是否能用sql做一个简单例子提示一下。

请先 登录 后评论

1 个回答

banxianer

柏木提供的答案:

官方提供的例子: testData = table(1 2 3 4 5 6 7 8 9 10 as `id,0 10 10 5 5 99 99 8 9 10 as `val) asof(cutPoints(testData.val,3),testData.val) 实际的例子: select symbol,LABORGETCASH, asof(cutPoints(int(LABORGETCASH)*100,5),LABORGETCASH) as lv from ( select date,symbol,round(LABORGETCASH \ 100000000,2) as LABORGETCASH from loadTable("dfs://stock","cn_finance_cashflow") where quarter = 'Q4'and year = 2021 ) where date = date('2021.12.31') 重点位cutPoints(x)的x必须为整数。

请先 登录 后评论
  • 1 关注
  • 0 收藏,945 浏览
  • 柏木 提出于 2022-06-14 15:33

相似问题