LoginSignup
1
3

More than 5 years have passed since last update.

Python / numpy > list > 与えられた行列から任意の位置の列リストを取り出す > Elist = src_data.T[3:] / 次元数による使い分け / PEP 3132 -- Extended Iterable Unpacking

Last updated at Posted at 2017-05-02

与えられた行列から、列リストを取り出す。

内包表記を使ってみた。

http://ideone.com/Vj9pxS
(Python3)

import numpy as np
amatrix = np.array([[3, 1, 4], [1, 5, 9], [2, 6, 5]])


l1, l2, l3 = [ amatrix[:, idx] for idx in range(0,3) ]
print(l1)
print(l2)
print(l3)
run
[3 1 2]
[1 5 6]
[4 9 5]

教えていただいた事項

@shiracamus さんに読みやすい実装を教えていただきました。
情報感謝です。

@knoguchi さんのコメントにて次元数による使い分けを教えたいただきました。
情報感謝です。

@shiracamus さんのコメントにてPEP 3132について教えていただきました。
情報感謝です。

1
3
12

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
3