add a column to a table kdb - Kdb+ / qStudio

Home Forums Kdb+ / qStudio add a column to a table kdb

Tagged: ,

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

    How can I add a column to a table in kdb?
    Is there an append column function?

    The easiest way to add a column is to use the update function. Below we show adding:
    1. A column of new data by specifying the list of values
    2. A new column that is calculated based on an existing column

    `

    q)table:([] a:1 2 3; b:”POI”)
    q)table
    a b

    1 P
    2 O
    3 I

    q)update newCol:8 9 10 from table
    a b newCol
    ———-
    1 P 8
    2 O 9
    3 I 10

    q)update newCol:a*10 from table
    a b newCol
    ———-
    1 P 10
    2 O 20
    3 I 30
    `

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.