1

As shown in the following script, I’d like to use a variable containing a list of column names as the metrics parameter in DolphinDB’s panel function.

fields=`factor1`factor2`factor3`factor4
res1=panel(tmp.quarter, tmp.order_book_id, fields, time, , parallel=true) 

Can someone please tell me how to write an effective script?

Eva Gao
  • 402
  • 1
  • 7

1 Answers1

2

Define a variable (i.e., metrics) to store the desired column names. Then, use t[metrics] to extract these columns and pass them as the metrics parameter in the panel function. Here's an example:

t = table(1 1 2 2 2 3 3 as id, 2020.09.01 + 1 3 1 2 3 2 3 as date, 1..7 as factor1, 4..10 as factor2);
metrics=["factor1", "factor2"]
panel(t.date, t.id, t[metrics], 2020.09.02 2020.09.03, 1 2)
Claire
  • 238
  • 4