column reordering kdb - Kdb+ / qStudio

Home Forums Kdb+ / qStudio column reordering kdb

Tagged: , ,

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #111313

    How do I reorder columns in kdb?
    I want to move some columns to the front and others to the end?

    We use the xcols function to reorder columns in kdb.

    – The first argument is a list of existing column names
    – The second argument is a table
    – The function reorders the columns to bring the column names specified to the start.

    e.g.

    `
    q)table:([] a:1 2 3; b:100.1 200.2 300.3; c:”TYH”; d:.z.d+1 2 3)
    q)table
    a b c d
    ——————–
    1 100.1 T 2016.09.29
    2 200.2 Y 2016.09.30
    3 300.3 H 2016.10.01
    q)’d’c xcols table
    d c a b
    ——————–
    2016.09.29 T 1 100.1
    2016.09.30 Y 2 200.2
    2016.10.01 H 3 300.3
    `

    If you want to rename columns in kdb see that link. Or if you get a length error when reordering with xcols see here.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.