Laura
Forum Replies Created
-
See also
If this reveals opportunities to improve the articles, please suggest them to librarian@kx.com.
-
The Reference lists for splay error: nyi op on splayed table. Does that help? Is there more to be said here?
-
Lets see what we can infer.
.quantQ.stats.kendallTauRank:{[xS;yS] //xS,yS -- arrays of values to compare the rank // aggregate concordance statictics stats: sum raze {.quantQ.stats.concordanceRoutine/:[y;(1+x?y)_x]}[t] each t: flip(xS,yS); // return kendall's tau rank :(stats[0]-stats[1])%0.5*count[xS]*count[xS]-1; }
flip(xS,yS)
tells us thatxS
andyS
must be same-width matrices otherwise there would be nothing to flip.The binary lambda
{.quantQ.stats.concordanceRoutine/:[y;(1+x?y)_x]}
is projected ont
, which thus becomes they
in the lambda.The lambda could equally be written
{y .quantQ.stats.concordanceRoutine/:(1+x?y)_x}
from which it might be clearer how, withx
set tot
, the binary concordance routine is being iterated: each row oft
against the rows that follow it.Two ways to express the same iteration:
raze{.quantQ.stats.concordanceRoutine/:[y;(1+x?y)_x]}[t] each t t .quantQ.stats.concordanceRoutine'(1+til count t)_: t
Line 6 defines the result. Omitting the explicit Return
:
and the trailing semicolon would be better style.stats
would be three integers; the difference could also be written-/[2#stats]
. -
A lot to unpack here but lets break it down.
.quantQ.IO.SAVEsPLAYtAB:{[tabPath;pvar;table] // tabPath -- path where to store the table // pvar -- variable to sort and index on for fast querying // table -- name of the table to save @[;pvar;`p#] pvar xasc (`sv (tabPath; ` ; table; `)) set .Q.en[tabPath] get table}
The three arguments are all symbols: respectively a file path, a table column name, and a table name. (It were best to state that in the comments.) Ill come to how we see that.
Lets set up a small table so we can watch what happens.
q)atable:([]ab:til 3;cd:`x`y`z;de:string`tom`**bleep**`harry) q)get `atable ab cd de ------------- 0 x "tom" 1 y "**bleep**" 2 z "harry" q)tabPath:`:path/to/table
The argument to
get
is the name of the table; the result is the table, which becomes the argument to.Q.en[tabPath]
.That is, binary
.Q.en
is projected ontotabPath
to make a unary. The effect is the same as if we had assigned the result ofget table
tot
and then called.Q.en[tabPath;t]
. What.Q.en
does is too extensive to discuss here but you can read up on it. The work it does is side effects; its result is the table.Which then gets passed as the right argument to
set
, which is quite a workhorse. Its syntax is overloaded, so we examine its left argument(` sv (tabPath; ` ; table; ` ) )
to see howset
is used here.The
sv
keyword is being called in this form, which is how we know thattabPath
andtable
must both be symbols. It returns a filehandle symbol as the left argument ofset
.From this we see that
set
is being called with syntaxtil set y // serialize y to fil
. It returns its left argument: the symbol filepath to which it has written the table; this becomes the right argument toxasc
, which will sort the table on disc by the column named bypvar
.The result is again a reference to the table, which becomes the argument to
@[;pvar;`p#]
, a projection of Apply At onto second and third argumentspvar
and`p#
. The effect is to set the partitioned attribute on the column named bypvar
. The result of Apply At is the table reference. Your code uses Explicit return:
to make that the result of.quantQ.IO.SAVEsPLAYtAB
. That is unnecessary: a functions result is the result of evaluating its last (here the single) expression. -
Laura
AdministratorFebruary 15, 2022 at 12:00 am in reply to: KX SQL Introductory Project – .s.e errorHi,
When you are coming back to this you may need to run a command using s) prompt before it will allow you to use .s.e.
Try running below first and then your command with .s.e
// SQL query using s) s)SELECT * FROM trips WHERE date=2009.01.01
-
Hi Luke,
Thanks for your question!
In the instance of archiving older dates in a HDB using the DC_ARCHIVE template, you would have to act upon the entire date partition anyway (as removing specific columns only within some partitions would break your HDB)
So in your example, your directory would be …/hdb/
and you would use the numDaysOlderThan parameter to archive dates older than X days.
Hope this helps!
Laura
-
example #1
- b defined globally as 6
- b defined locally as 42 using colon :
- b defined globally as x (98) using set
- local b returned as 42
- global b returned as 98
example #2
- b defined globally as 6
- b defined locally as 42 using colon :
- nothing is happening as set without backtick does not do assignment
- local b returned as 42
- global b returned as 6
So the reason for this behavior has more to do with function scoping than backtick. You can learn more about function scoping (defining locally verses globally) here, specifically around 4.30mins you can see in action the two ways of defining variables globally – using set and double colon.
Hope this helps!
-
Hi Ypangalela,
Backtick represents a symbol. In your example the function of $ is to cast (or transform) a string to a symbol – see more examples here https://code.kx.com/q4m3/7_Transforming_Data/#732-creating-symbols-from-strings
and also here https://kx.com/learning/modules/casting/#casting-methodsHope this is helpful/
Thanks,
Michaela
-
Hi ,
I see you’ve asked a new thread about cointegration so we can continue our conversation over there: Johansen cointegration test kdb+ implement – KX Learning Hub
Thanks,
Laura
-
Hi
If you want to keep the nanosecond granularity, you will have to keep the value as a timespan, and the prefacing 0D.
You can see some more examples of time conversions here: https://code.kx.com/q/kb/temporal-data/#comparing-temporals
Hope that helps clarify, and thanks for your questions!
Laura
-
Laura
AdministratorJanuary 13, 2022 at 12:00 am in reply to: Johansen cointegration test kdb+ implementHi ,
I haven’t seen the implementation done in kdb+, however we do have over 121 interfaces and connectors including Python and R, which (after a brief google) I was able to see implementation examples of online.
If you are working on this implementation in kdb+, we would love you to share with the Community, I know many of us would be very interested to see your approach!
Good luck, and thanks for your question,
Laura
-
Hi jetz,
Thank you for checking out the Academy and KX Sandbox!
The sandboxes are only provisioned for a limited time ( less than 24hours) so if you are working on something we recommend you download at end of day and reupload the file when you come back to work on it in a new sandbox. Guidance below on how to provision a clean new sandbox if you are seeing errors.
I cant login with learn.kx.com/KX Sandbox?
To debug connection Issues with learn.kx.com you should try the following actions:
- Clear caches & cookies and try again
- Try in launching sandbox from a different incognito/private browsing mode in another browser provider. Note we recommend always running learn.kx.com in incognito/private browsing mode as it is less error prone
- Some clients (usually high security banks) will have learn.kx.com blocked – suggest user tries on their own personal PC
Let us know if this helps and if you have any further issues.
Thanks,
Michaela
-
Laura
AdministratorDecember 20, 2021 at 12:00 am in reply to: How to setup KX Developer IDE workspace with specific Q and C/C++ integrationHi Ori,
You don’t need to check out a repository in order to start working with Developer.
Have you installed Developer locally on your machine?
If so, when you first open the browser UI , you will be greeted with a pop up called “Developer Workspace Browser” – you can create a new workspace here and then use the scratch pad to create the data/functions or access the data from your local machine (You can use Tools > Table Importer to do this)
Then you are free to use everything else under Tools, such as the visual inspector to visualize your data.
Hope this helps!
Laura
-
Laura
AdministratorDecember 20, 2021 at 12:00 am in reply to: How to setup KX Developer IDE workspace with specific Q and C/C++ integrationHi Ori,
Sorry to hear this.
The table importer supports data in csv format, but only accepts one table at a time as it would not be able to differentiate between multiple tables in one xslx file.
My suggestion would be to save each as individual csv files, and load one at a time so that you can ensure each table is of the correct format and types.
I would highly recommend the Introduction to Developer course on KX Academy (if you have not already seen it) for step-by-step guidance through the table importer functionality.
Let us know how you get on, and if you have any more questions.
Laura
-
Laura
AdministratorDecember 20, 2021 at 12:00 am in reply to: How to setup KX Developer IDE workspace with specific Q and C/C++ integrationHi Ori,
Of course, our support team can help if you reach out through our support channels here: Support for KX products – Product documentation
Otherwise, if you can post the error message here without revealing your data, I’d be happy to continue de-bugging with you.
Laura