I've got an empty structured array:
id_and_orders_type = np.dtype([('id', 'i4'), ('order_values', 'f4', (100,))])
id_and_orders = np.zeros((10,), dtype=id_and_orders_type)
and I've got another structured array with the data to be filled into id_and_orders
.
orders_type = np.dtype([('id', 'i4'), ('value', 'f4')])
orders = np.array(((1, 33.2), (2, 37.1), (3, 22.1), (2, 63.9), (3, 93.1)), dtype=orders_type)
what I wanna do now is to map every orders['value']
with its corresponding id
in id_and_orders
. In a way that id_and_orders
would contain orders['id']
with a subarray of the values for that id in orders
:
id_and_orders = np.array(((1, (33.2,), (2, (37.1, 63.9), (3, (22.1, 93.1)))
and maybe some would know how to build the size of the subarray id_and_orders['order_values']
dynamically and not fixed sized with 100.