kdb

how to use ungroup with multiple composite columns in kdb

[亡魂溺海] 提交于 2021-02-08 06:34:30
问题 Consider the following table: `Keys `Values `A`B `V1`V2 `C`D`E `V1`V2`V3`V4 I want to flatten the Keys column only such that each key is mapped to the corresponding Values. The result should be: `Keys `Values `A `V1`V2 `B `V1`V2 `C `V1`V2`V3`V4 `D `V1`V2`V3`V4 `E `V1`V2`V3`V4 ungroup function applies ungroup to all columns, in this case I want to apply to Keys column alone. 回答1: Few different ways you can go about this, below is one way - ungroupCol:{[tbl;col] @[tbl where count each tbl col

kdb/q: How to apply a string manipulation function to a vector of strings to output a vector of strings?

不打扰是莪最后的温柔 提交于 2021-02-05 08:18:51
问题 Thanks in advance for the help. I am new to kdb/q, coming from a Python and C++ background. Just a simple syntax question: I have a string with fields and their corresponding values pp_str: "field_1:abc field_2:xyz field_3:kdb" I wrote an atomic (scalar) function to extract the value of a given field. get_field_value: {[field; pp_str] pp_fields: " " vs pp_str; pid_field: pp_fields[where like[pp_fields; field,":*"]]; start_i: (pid_field[0] ss ":")[0] + 1; end_i: count pid_field[0]; indices:

kdb/q: How to apply a string manipulation function to a vector of strings to output a vector of strings?

天大地大妈咪最大 提交于 2021-02-05 08:18:10
问题 Thanks in advance for the help. I am new to kdb/q, coming from a Python and C++ background. Just a simple syntax question: I have a string with fields and their corresponding values pp_str: "field_1:abc field_2:xyz field_3:kdb" I wrote an atomic (scalar) function to extract the value of a given field. get_field_value: {[field; pp_str] pp_fields: " " vs pp_str; pid_field: pp_fields[where like[pp_fields; field,":*"]]; start_i: (pid_field[0] ss ":")[0] + 1; end_i: count pid_field[0]; indices:

KDB - Referencing functions from a table

喜夏-厌秋 提交于 2021-01-06 03:34:53
问题 I am new to kdb and researching it for a use case to generate time series data using a table of various function inputs. Each row of the table consists of function inputs keyed by an id and segment and will call one function per row. I have figured out how to identify which function albeit using brute force nested conditions. My question is 2 part How does one employ kicking off the execution of these functions? Once the time series data is generated for each id and segment, how best can the

KDB - Referencing functions from a table

风流意气都作罢 提交于 2021-01-06 03:30:01
问题 I am new to kdb and researching it for a use case to generate time series data using a table of various function inputs. Each row of the table consists of function inputs keyed by an id and segment and will call one function per row. I have figured out how to identify which function albeit using brute force nested conditions. My question is 2 part How does one employ kicking off the execution of these functions? Once the time series data is generated for each id and segment, how best can the

KDB - Referencing functions from a table

丶灬走出姿态 提交于 2021-01-06 03:29:27
问题 I am new to kdb and researching it for a use case to generate time series data using a table of various function inputs. Each row of the table consists of function inputs keyed by an id and segment and will call one function per row. I have figured out how to identify which function albeit using brute force nested conditions. My question is 2 part How does one employ kicking off the execution of these functions? Once the time series data is generated for each id and segment, how best can the

using .Q.dpft function to resave table

筅森魡賤 提交于 2020-12-15 03:54:43
问题 I am trying to load the data for each date and then sort the sym column and apply the parted attribute. But I don’t know how to use the .Q.dpft function to save to the same table? There is a trade table in hdb. Here is my function: \l dbdir; test:{ trade:select from trade where date = x; trade:`sym xasc trade; .Q.dpft[dbdir;x;`sym;`trade]}each date; Doesn’t seem to be working though. The error is ``trade` 回答1: I think you need to pass the table trade & dbdir as arguments to your function