python - how to efficiently link lines of numpy array to sets of tags? -
i trying convert list of data structure, of same type, numpy arrays. works number attributes there 1 attribute value set of tags (strings). , don't see how model numpy .
so far, use 2d array. each row contains attributes of 1 data structure, 1 per columns. set of strings, don't know how use in numpy array.
it seems can put set value cell in array seems break point of numpy : fixed size arrays efficient functions apply on them.
any idea ?
i think best alternative use list of tuples
supposing l list:
in [1]: l = [[4,5,6,'a','b'],['x','y',2,3]] in [2]: _l = [tuple(elem) elem in l] in [3]: _l out[1]: [(4, 5, 6, 'a', 'b'), ('x', 'y', 2, 3)]
alternatively create list of tuple first element of tuple numpy array, , second element tag.
Comments
Post a Comment