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 配列ベクトルがあり、インデックスに基づいてサブセットを取得したい:
import numpy as np input=np.array([1,2,3,4,5,6,7,8,9,10]) index=np.array([0,1,0,0,0,0,1,0,0,1])
output=[2,7,10] を取得する Pythonic の方法は何ですか?
output = input[index.astype(np.bool)]
また
output = input[np.where(index)[0]]