KX Community

Find answers, ask questions, and connect with our KX Community around the world.

Home Forums kdb Insights How to convert sym columns to guid or to original data

  • How to convert sym columns to guid or to original data

    Posted by mario on March 18, 2024 at 3:18 am

    I have schema like

    ([]time:timespan$();sym:$();user_uuid:$();order_id:long$();instrument:`$())

    when I feed using qpython suddenly, the all symbol column convert to something like int, meanwhile original data for sym is uuid, user_uuid is uuid, instrument was string How to solve it using pykx?

    • This discussion was modified 2 months, 1 week ago by  mario.
    rocuinneagain replied 2 months, 1 week ago 2 Members · 3 Replies
  • 3 Replies
  • rocuinneagain

    Member
    March 19, 2024 at 11:29 am

    Can you include some more code to explain what the issue is?

    To create a symbol vector you are using:

    `symbol$()

    but you should use:

    `$()

    .i.e

    q)order_histories:([]time:`timespan$();sym:`$();user_uuid:`$();order_id:`long$();instrument:`$())
    q)order_histories
    time sym user_uuid order_id instrument
    --------------------------------------

    Insert some data and set a port:

    q)order_histories insert (2?.z.N;2?`6;2?`6;2?100000;2?`6)
    0 1
    q)order_histories
    time sym user_uuid order_id instrument
    ---------------------------------------------------------

    0D09:21:01.649029855 kfmohp kfhogj 81418 milgli
    0D05:24:41.981647398 lkklco jecpae 75009 igfbag
    q)\p 5000

    Query from PyKX

    >>> import pykx as kx
    >>> conn('order_histories')
    pykx.Table(pykx.q('
    time sym user_uuid order_id instrument
    ---------------------------------------------------------
    0D09:21:01.649029855 kfmohp kfhogj 81418 milgli
    0D05:24:41.981647398 lkklco jecpae 75009 igfbag
    '))
    >>> conn('order_histories').pd()
    time sym user_uuid order_id instrument
    0 0 days 09:21:01.649029855 kfmohp kfhogj 81418 milgli
    1 0 days 05:24:41.981647398 lkklco jecpae 75009 igfbag
    • This reply was modified 2 months, 1 week ago by  rocuinneagain.
  • mario

    Member
    March 20, 2024 at 4:21 pm

    my all sym column got integer result with format

    pykx.SymbolAtom(int value) then I am using py() still got int value

    • This reply was modified 2 months, 1 week ago by  mario.
    • rocuinneagain

      Member
      March 20, 2024 at 4:37 pm

      Can you share a small sample of your PyKX code which shows the issue?

Log in to reply.