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.
From a masked 2d array like this: (x = --)
x
--
x x x x x 5 6 x x x x x x x 9 x
How can I get: (confining the edges as much as possible until reaching a number)
5 6 x x x 9
Thanks.
スライスを使用してください:-)
slice = x[1:, 1:-1]
エッジをトリミングすることもできます。
while all(x.mask[0, :]): x = x[1:, :] while all(x.mask[-1, :]): x = x[:-1, :] while all(x.mask[:, 0]): x = x[:, 1:] while all(x.mask[:, -1]): x = x[:, :-1]