scikit-learn Cookbook(Second Edition)
上QQ阅读APP看书,第一时间看更新

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])