KX Community

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

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

  • 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 5 months, 3 weeks ago by  rocuinneagain.