How to do ema on reactive state engine excluding NULL values

Hi,

I have data stream which have NULL values in them. I want to perform ema on them. But I want to exclude the NULL when doing ema but I cannot remove the entire line in append message function.

As of now I tried using dropna() but it didnt give any useful results.

Reply as soon as possible.

Note:-

I cannot use filter condition (select * from msg where jc==1) when subscribing to reactive state engine because I need all of the data.

Sample Data:-

z.zip

Code:-

a=table(1000:0,`symbol`ts`price`jc`a1`a2`a3,[SYMBOL,TIMESTAMP,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE])

r1=createReactiveStateEngine(name="r1",metrics=<[ts,price,jc1,tmavg(ts,jc1,3m),ema(dropna(jc1),3),tmavg(ts,p1,3m)]>,dummyTable=z,outputTable=a,keyColumn=`symbol);

replay(inputTables=z,outputTables=r1,dateColumn=`ts)


Output:-attachments-2022-01-Y0LGUb4T61f7dd67826b0.png


When I manually select with dropna() it gives correct answer

Code:- (they both give correct answer)

ema(dropna(z.jc1),3)

b=1 2 3 4 5 6 7 8 9

ema(b,3)


Output:-

attachments-2022-01-Mqy07kuK61f7ded04787f.png

请先 登录 后评论

1 个回答

Shena Mao

Happy Lunar New Year!

What kind of result do you want to get? As you know that if you drop null value, there would be only 9 records. However, other columns contain thousand.

If you want your result filling each row, you could do ema(filter condition to drop null value when subscribe) and other metrics separately and then using asofjoinengine to combine them.

how to use AsofJoinEngine, you could refer to:

https://www.dolphindb.cn/cn/help/200/FunctionsandCommands/FunctionReferences/c/createAsofJoinEngine.html

请先 登录 后评论
  • 1 关注
  • 0 收藏,947 浏览
  • Vishvesh Upadhyay 提出于 2022-01-31 20:46

相似问题