KX Community

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

Home Forums PyKX How to transform pykx list of lists to .np() matrix Re: How to transform pykx list of lists to .np() matrix

  • cmccarthy1

    Member
    August 29, 2023 at 12:00 am

    Hey,

    There isn’t presently a way for multi-dimensional arrays to be returned in a different representation by default, if the returned data is a ‘rectangular’ data representation you can call np.stack on the data post processing to flatten it’s representation if needed

    >>> import pykx as kx 
    >>> import numpy as np 
    >>> arr = kx.toq(np.random.rand(3,2))
    >>> np.stack(arr.np()) 
    array([[0.98669419, 0.47121857], 
    [0.27329073, 0.15091775], 
    [0.30553385, 0.32638803]])