I am having problems when indexing empty numpy arrays with empty lists.
It works fine for one-dimension arrays:
>>> a = ones(0)
>>> a
array([], dtype=float64)
>>> ind = []
>>> a[ind]
array([], dtype=float64)
If I create an empty array with 3 columns, I get an error:
>>> b = ones((0, 3))
>>> b
array([], shape=(0, 3), dtype=float64)
>>> b[ind]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: invalid index
I am trying to extract no rows from an array with 0 rows and 3 columns. I would expect to get an empty 0x3 array, the same as I get when the array is not empty:
>>> c = ones((2, 3))
>>> c
array([[ 1., 1., 1.],
[ 1., 1., 1.]])
>>> c[ind]
array([], shape=(0, 3), dtype=float64)
Is there a reason why it doesn't work for empty 2-dimensional arrays? Is there any way to make this work in python?
numpy
version1.8.2
– plonser Apr 10 at 8:421.6.1
. Thanks, I will update to newer version – burak1000 Apr 10 at 8:48