Indexing

  1. Look up the values of the two-dimensional arrays with indexing:
array_1[0,0]   #Finds value in first row and first column.1
  1. View the first row:
array_1[0,:]array([1, 2])
  1. Then view the first column:
array_1[:,0]array([1, 3, 5, 7, 9])
  1. View specific values along both axes. Also view the second to the fourth rows:
array_1[2:5, :]array([[ 5,  6],       [ 7,  8],       [ 9, 10]])
  1. View the second to the fourth rows only along the first column:
array_1[2:5,0]array([5, 7, 9])

Get scikit-learn Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.