Suppose I have the following array.
l = np.asarray([1,3,5,7])
Out[552]: array([1, 3, 5, 7])
I can select the row twice using a index array np.asarray([[0,1],[1,2]]):
l[np.asarray([[0,1],[1,2]])]
Out[553]:
array([[1, 3],
[3, 5]])
It doesn't work if the index array have different length on each row:
l[np.asarray([[1,3],[1,2,3]])]
Traceback (most recent call last):
File "<ipython-input-555-3ec2ab141cd4>", line 1, in <module>
l[np.asarray([[1,3],[1,2,3]])]
IndexError: arrays used as indices must be of integer (or boolean) type
My desired output for this example would be:
array([[3, 7],
[3, 5, 7]])
Can someone please help?