python - Using every first element in a multidimensional array -


i had thought if ran perhaps print mdarray[::][1], print first sub-element of every element in array. did go wrong this?

i need p.plot(x,y[::][1]) not want use loop, horribly slow, unless i'm getting things confused.

what getting wrong? thanks!

edit

i still don't know got [::] thing solved problem either

p.plot(x,c[:,1],color='g',label="closing value")

or

p.plot(x,[i[1] in c],color='g',label="closing value") 

there doesn't seem appreciable difference in time, guess i'll use second because looks more pythonic/readable me. or missing something?

thanks of help!

what did:

you used mdarray[::]. makes (shallow) copy of mdarray. accessed second element of [1]. [0] first.

what can list comprehension:

[item[0] item in mdarray] 

this return list of first elements of lists in mdarray.

talking loops: (one time) loop rather effective access something. internally magic functions (like comprehension above) iterating on data.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -