numpy - python ndarray perform A[:, ... , l, .. :] at specific index -
this question has answer here:
suppose have np.ndarray a of variable known shape. perform operation a[:, ... , :, l , :, ... : ] l known integer occurs @ known index i in [...].
there rather easy solution have searched internet , couldn't find anything.
you can add arbitary number of dimensions in []:
[(slice(none), ) * + (l, )] this equivalent of i :, , l. example:
i = 2 l = 3 a[(slice(none), ) * + (l, )] would equivalent to:
a[:, :, 3]
Comments
Post a Comment