KX Community

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

Home Forums kdb+ Why creating a table from a tale results in a list of dictionaries? Re: Why creating a table from a tale results in a list of dictionaries?

  • cillianreilly

    Member
    June 19, 2023 at 12:00 am

    First, remember that a table itself is just a list of dictionaries.

    q)0N!/:tab; 
    `col1`col2!(`a;1) 
    `col1`col2!(`b;2) 
    `col1`col2!(`c;3)

    So, when you tabulate a table, each entry in the original table (a dictionary) just becomes an entry in the new table column:

    q)([]tab) 
    tab 
    ----------------- 
    `col1`col2!(`a;1) 
    `col1`col2!(`b;2) 
    `col1`col2!(`c;3) 
    
    q)type ([]tab) 
    98h 
    
    q)type each tab 
    99 99 99h 
    
    q)type each([]tab) 
    99 99 99h