I have a 2d array in the numpy module that looks like:
data = array([[1,2,3],
[4,5,6],
[7,8,9]])
I want to get a slice of this array that only includes certain columns of element. For example I may want columns 0 and 2:
data = [[1,3],
[4,6],
[7,9]]
What is the most Pythonic way to do this? (No for loops please)
I thought this would work, but it results in a "TypeError: list indices must be integers, not tuple"
newArray = data[:,[0,2]]
Thanks.