I read from a file with loadtxt
like this
data = loadtxt(filename) # id x1 y1 x2 y2
data
could look like
array([[ 4. , 104.442848, -130.422137, 104.442848, 130.422137],
[ 5. , 1. , 2. , 3. , 4. ]])
I can then reduce data
to the lines belonging to some id
number:
d = data [ data[:,0] == id]
The problem here is when the data contain only one line.
So my question is how to check the 2-dimensionality of my array data
?
I tried checking
data.shape[0] # num of lines
but for one-liners I get something like (n, )
, so this will not work.
Any ideas how to do this correctly?