Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は次の形式のnumpy配列を持っています:
a = [[1,2,3],[4,5,6],[7,8,9]]
要素を次のように抽出したい:
a' = [[1,2],[4,5],[7,8]]
私は使ってみました:
a' = a[:][:2]
しかし、それは私が期待したようには機能しません
>>> [l[:2] for l in a] [[1, 2], [4, 5], [7, 8]]
>>> numpy.array([[1,2,3],[4,5,6],[7,8,9]])[:,:2] array([[1, 2], [4, 5], [7, 8]])