1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python > a[0] > for multidimensional a, a[0] is interpreted by taking all elements in the unspecified dimensions.

Posted at

@ Scipy lecture notes, Edition 2017.1
https://www.scipy-lectures.org/_downloads/ScipyLectures-simple.pdf
p54
https://www.scipy-lectures.org/intro/numpy/array_object.html#indexing-and-slicing

for multidimensional a, a[0] is interpreted by taking all elements in the unspecified dimensions.

意訳「多次元aの場合、a[0]は不定次元の全要素と解釈される」

import numpy as np

ary = np.eye(3)
print(ary)
print(ary[0])

run
[[ 1.  0.  0.]
 [ 0.  1.  0.]
 [ 0.  0.  1.]]
[ 1.  0.  0.]

a[0]を使うと間違いにつながる、という認識を持った。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?