From 0bd0efe88b2ff8ab60a6fbfb8cb55c751943a104 Mon Sep 17 00:00:00 2001 From: marcosvm13 <61940472+marcosvm13@users.noreply.github.com> Date: Thu, 28 Sep 2023 15:05:07 +0200 Subject: [PATCH] Update 2023-09-15-All-Roads-Lead-To-Kdb:-Technical-Counterpart.html --- ...ds-Lead-To-Kdb:-Technical-Counterpart.html | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/_posts/2023-09-15-All-Roads-Lead-To-Kdb:-Technical-Counterpart.html b/_posts/2023-09-15-All-Roads-Lead-To-Kdb:-Technical-Counterpart.html index 6219310..119a15b 100644 --- a/_posts/2023-09-15-All-Roads-Lead-To-Kdb:-Technical-Counterpart.html +++ b/_posts/2023-09-15-All-Roads-Lead-To-Kdb:-Technical-Counterpart.html @@ -1559,14 +1559,13 @@
Keyed table indexing is different; that's why if we want to see the
- first values of the table, we need to use the #
- (take) operator.
Now traffic is a keyed table. Keyed tables indexing is a bit different; that's why if we want to see the + first values of the table, we need to use the sublist method.
print(kx.q("3#",traffic))
+ class="sourceCode python">print(kx.q.sublist(3,traffic))
- Moreover, the application of q iterations could be - another avenue of exploration:
- >>> kx.q("lower").each(['A', 'B', 'C'])
- `a`b`c
- Finally, you can even create functions and use them with PyKX or Python objects.
- >>> kx.q("{u !(sum x=) each u:distinct x}", ['A', 'B', 'B', 'B' ,'C'])
+ Moreover, the application of q iterations could be another avenue of exploration. You can even create functions and use them with PyKX or Python objects using Lambda functions (as we have done thus far) or by applying a composition of functions to the Python object:
+ >>> kx.q.count.each(kx.q.group(['A', 'B', 'B', 'B' ,'C']))
A| 1
B| 3
- C| 1
+ C| 1
= kx.q.each(kx.q('{first where x=min x}'), dist)
+ class="sourceCode python"> ids = kx.q.each(kx.q('{x?min x}'), dist)
ids = kx.q('{traffic_station ^ weather_station[x]}' , ids)
distance_table = kx.q.qsql.delete(distance_table, columns = ['tipo_elem','distrito','cod_cent','nombre','utm_x','utm_y','longitude', 'latitude']) distance_table
"5#",complete).pd() kx.q(
+ class="sourceCode python">3,complete).pd() kx.q.sublist(