I would like to delete [[23][01][01]]
which is the opposite combination of [[01][23]]
in Python's three-dimensional ndarray array as shown below.
import numpy as np
arr1 = np.array([[0,1], [2,3]],
[[4, 5], [6, 7]],
[[2, 3], [0, 1]],
[[2, 3], [4, 5]],
[[6, 7], [4, 5]],])
arr2 = np.array([[0,1], [2,3]],
[[4, 5], [6, 7]],
[[2, 3], [4, 5]],])
I would appreciate it if you could let me know as it is not going well.
Thank you for your cooperation.
If you don't mind changing the order:
import numpy as np
arr1 = np.array(
[[[0, 1], [2, 3]],
[[4, 5], [6, 7]],
[[2, 3], [0, 1]],
[[2, 3], [4, 5]],
[[6, 7], [4, 5]]])
print(np.unique(np.sort(arr1,axis=1),axis=0))
# [[[0 1]
# [2 3]]
#
# [[2 3]
# [4 5]]
#
# [[4 5]
# [6 7]]]
© 2024 OneMinuteCode. All rights reserved.