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 @@

Traffic

-

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))
@@ -1653,6 +1652,10 @@

Traffic

+
+ 🔍 Version 2.0.0 of PyKX brings significant improvements in this regard, making the pandas API a viable option for such migrations. Regrettably, at the time when the post was created, these essential functions were not yet available. But now we have functions like groupby and flags/imports are no longer needed. + +

Weather

@@ -1844,21 +1847,12 @@

Weather

When Python objects have a direct equivalent in q, like dictionaries, they can be directly employed as attributes for PyKX functions. Beneath the surface, PyKX adeptly manages the conversion to q data structures.

-

- 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

+ @@ -2523,7 +2517,7 @@

Location

ids = kx.q.each(kx.q('{first where x=min x}'), dist)
+        class="sourceCode python">ids = kx.q.each(kx.q('{x?min x}'), dist)
 distance_table = 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'])
@@ -2592,7 +2586,7 @@

Final Table

kx.q("5#",complete).pd()
+ class="sourceCode python">kx.q.sublist(3,complete).pd()
@@ -3273,6 +3267,14 @@

Final references to continue learning PyKX. Have fun with PyKX!

+ +

Acknowledgments

+ + We would like to express our gratitude to the KX team for their valuable advice and feedback. Special thanks + to Ferenc Bodon for suggesting several improvements. + +
+

Bibliography

  • Vidas M, Tubić V, Ivanović I, Subotić M. Sustainability (Basel)