import numpy as np
x = np.arange(12).reshape(3, 4)
print(x)
idx = np.array([0, 1])
y = x[:2, idx : idx + 2]
# should be
# [[0 1]
# [5 6]]
So I want to get different slice for each row. In this example, it's the 0, 1
indexes from the first row and 1, 2
indexes from the second row.
Instead, I'm getting:
TypeError: only integer scalar arrays can be converted to a scalar index
What are my options? Are there more than one? Any performance implications?