Say I have the following 2d array:
[[a, a, a, a],
[a, a, b, a],
[a, a, b, a],
[a, c, c, a],
[a, a, a, a]]
And I want to transform it into the following:
[[a, a, a, a],
[a, a, d, a],
[a, a, d, a],
[a, d, d, a],
[a, a, a, a]]
I am currently doing it in 2 steps: like arr[1:4,2]=d and arr[3, 1:3]=d
Is there a way to do it in only one step, which would also not impact the performance?
Probably it is not possible, you can't get L shape in just on slicing, need at least 2 slicings to form an L.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.