pythonのnumpyのdigitizeについての質問です。
numpyの機能で3次元配列に対してビンを作成したいのですが、
1次元の配列ならうまくいきますが、多次元になると怒られます。
できればfor文やリスト内表記を使わずいっぺんに出したいのですが、なにかいい方法はありませんでしょうか?
import numpy as np import random if __name__ == "__main__": bins = np.array([[[0, 20, 50, 60, 127],[0, 30, 50, 70, 127],[0, 20, 50, 80, 127]], [[0, 20, 50, 60, 127],[0, 30, 50, 70, 127],[0, 20, 50, 80, 127]], [[0, 20, 50, 60, 127],[0, 30, 50, 70, 127],[0, 20, 50, 80, 127]]]) x = np.array([0, 12, 26, 39, 67,98,127,0, 6,110,127]) indices = np.digitize(x, bins[:,:])-1 print(indices) エラー文 indices = np.digitize(x, bins[:,:])-1 ValueError: object too deep for desired array

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/24 06:31 編集
2019/01/24 06:33
2019/01/24 06:52