python - Error when accessing element in structured array -


1i using structured array save measurements sensor. array (named "data") of dimension 2000x3 3 fields: "samples", "timestamp" , "labels", samples vector of 6 elements. example, 1 row looks this:

([-19.837763650963275, -19.61692779005053, -18.5301618270122, -13.413484985874076, -13.192649124961326, -12.105883161923], 0.0, 0) [('samples', '<f8', (6,)), ('timestamp', '<f8'), ('labels', '<i4')] 

if want have samples of 1 row access row this:

data["samples"][10] 

which works fine if turn around , write this:

data[10]["samples"] 

i following error:

valueerror: truth value of array more 1 element ambiguous. use a.any() or a.all()

does know why happening?

edit: better understanding here first 10 rows of "data" array:

[ ([-19.837763650963275, -19.61692779005053, -18.5301618270122,       -13.413484985874076, -13.192649124961326, -12.105883161923], 0.0, 0)  ([-18.66282477705446, -18.449317421024432, -17.369283339067675, -12.357118609142269, -12.145937637117552, -11.068086720774204], 0.0, 0)  ([-17.69388207920866, -17.49198382816449, -16.417085567075173, -11.53193799727324, -11.33976221074188, -10.268890664091229], 0.0, 0)  ([-16.868088042481606, -16.683019283158636, -15.610803357043569, -10.88697503359368, -10.732729221349611, -9.663174869208511], 0.0, 0)  ([-16.152597338007514, -15.99074244228478, -14.917542852993487, -10.420257243109129, -10.371835643625495, -9.274470774420056], 0.0, 0)  ([-15.527885804583931, -15.39736918876727, -14.317660328685264, -10.451759205557037, -10.011944429521288, -9.006031495483906], 0.0, 0)  ([-14.981993405744573, -14.894234811642814, -13.799157258392123, -10.01393043959338, -9.563854671143899, -8.587392657229502], 0.0, 0)  ([-14.508475562047407, -14.48315918653869, -13.355984261155621, -9.577456476813333, -9.16920566037696, -8.205174149255923], 0.0, 0)  ([-14.106856958780497, -14.199089434545343, -12.989626950396643, -9.214711746255777, -8.944244361010687, -7.942834820090279], 0.0, 0)  ([-13.789298779585817, -13.943732248940886, -12.72321280228509, -9.208476598556874, -8.629970466866272, -7.690122078593869], 0.0, 0)]

edit 2: i'm using numpy version 1.10.4

and i'm not using

data[0]["samples"] 

but tried , doesn't work well. i'm using way:

for row in data:     print(row["samples"])

i did basic example think of , works surprisingly:

i did basic example think of , works surprisingly:

a = np.zeros(10, dtype = [("a", "5f8"), ("b", "i4")])     print(a["a"][5])   # works      print(a[5]["a"])   # surprisingly works 


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -