Last active
May 14, 2019 11:34
-
-
Save yubessy/e22186b6669ad14736ec to your computer and use it in GitHub Desktop.
Python3の...(Ellipsisオブジェクト)について ref: https://qiita.com/yubessy/items/cc1ca4dbc3161f84285e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> b = numpy.array([[[1, 2], | |
... [3, 4]], | |
... [[5, 6], | |
... [7, 8]]]) # 2x2x2の多次元配列 | |
>>> b[..., 0] # 第1, 2次元は任意、第3次元のインデックスは0 ---(1) | |
array([[1, 3], | |
[5, 7]]) | |
>>> b[:, :, 0] # (1)と同義 | |
array([[1, 3], | |
[5, 7]]) | |
>>> b[:, 0] # 第1次元は任意、第2次元のインデックスは0、第3次元のインデックスは任意 ---(2) | |
array([[1, 2], | |
[5, 6]]) | |
>>> b[:, 0, :] # (2)と同義 | |
array([[1, 2], | |
[5, 6]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> str(Ellipsis) | |
'Ellipsis' | |
>>> str(pass) | |
File "<stdin>", line 1 | |
str(pass) | |
^ | |
SyntaxError: invalid syntax |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> a[0, :] | |
array([1, 2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment