This community-built FAQ covers the “Selecting Elements from a 2-D Array” exercise from the lesson “Introduction to NumPy”.
Paths and Courses
This exercise can be found in the following Codecademy content:
Data Science
Introduction to Statistics with NumPy
FAQs on the exercise Selecting Elements from a 2-D Array
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply (
) below!
Agree with a comment or answer? Like (
) to up-vote the contribution!
Need broader help or resources? Head here.
Looking for motivation to keep learning? Join our wider discussions.
Learn more about how to use this guide.
Found a bug? Report it!
Have a question about your account or billing? Reach out to our customer support team!
None of the above? Find out where to ask other questions here!
it is said in the lesson that " A two-dimensional array has two axes: axis 0 represents the values that share the same indexical position (are in the same column), and axis 1 represents the values that share an array (are in the same row)"
But whenever we are getting elements from an array, we specify rows and columns so how does the above statement fits in here? Can someone give an example where we would use these axis 0 and axis 1?
I also didn’t understand the explanation given. But it’s pretty simple actually, as it is just a coordinates system, in which:
a[2, 0]
- a = name of your array
- 2 = the first digit is the array you wish to select within the zero indexed 2D grid.
In this case is the third array (0, 1, 2
)
- 0 = the second digit is the position within the selected zero indexed array.
In this case we’re selecting the second digit of the selected array (0
, 1, 2, 3, 4).
Vishal created a good visual example in this post, I will post it here to illustrate what I’m talking about:

In the context of this exercise, the code:
tanya_test_3 = student_scores[2, 0]
print(tanya_test_3)
would return 87
Note that you can replace the first or second digit with “:” to select whole arrays or columns. For example, in the context of this exercise the code:
cody_test_scores = student_scores[:,4]
print(cody_test_scores)
translates to something like “select all arrays from the student_scores 2D array and return the position 4 of all of them”.
This would return the array [87 91 92], storing it in the cody_test_scores variable
Hope it helps. Cheers! 
@awsomecodecademy I hope you don’t mind me borrowing your awesome visual

3 Likes
Thanks for your explanation. I was actually asking for axis in general but the visual explains the negative indexing nicely.
I found my question in a response by someone:
When applying certain Numpy functions like np.mean()
, we can specify what axis we want to calculate the values across.
For axis=0
, this means that we apply a function along each “column”, or all values that occur vertically.
For axis=1
, this means that we apply a function along each “row”, or all values horizontally.
1 Like
@corepro76625 No no I’m totally Fine and actually feeling really Great that i created a post that could help others. I was also confused with this concept at first so i tried and then made this picture.
That’s Wonderful to know. 

1 Like