1

If I have an NxN NumPy array, and I wanted to get all rows of data from just the 5th column, is there any difference between the following methods:

just_the_fifth_a = somearray[0::,4]

just_the_fifth_b = somearray[0:,4]

just_the_fifth_c = somearray[:,4]
3
  • somearray[:-1,4] too. What are you looking for in terms of differences? Commented Jan 24, 2016 at 1:38
  • somearray[:-1,4] lops a value off the end. But the stop value may be the shape or larger, or may be None. Commented Jan 24, 2016 at 3:13
  • I was just looking through a tutorial and noticed that it used all of the styles I mentioned and was wondering if there was a reason for the inconsistency other than exposing reader to different styles. Commented Jan 24, 2016 at 22:35

1 Answer 1

1

No there is no difference between the three posted methods. You could do somearray[::,4] as well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.