I have two numpy
arrays: X
with shape of (n, 16928)
, and y
with shape of (n,1)
.
I would like to merge the two arrays, drop the duplicated rows if any, and "unmerge" the result back in separate arrays X
and y
. I was able to merge two arrays, but how do I split them back?
Edit
Here is an example:
X = np.array([
[1,2,3,4,5,6,7],
[2,3,4,5,6,7,8],
[3,4,5,2,1,4,5],
[1,2,3,4,5,6,7],
[1,2,3,4,5,6,7],
[1,2,3,4,5,6,7],
])
y = np.array([
[2.],
[3.],
[4.],
[2.],
[3.],
[4.],
])
Expected result
>>> X, y
(array([[1, 2, 3, 4, 5, 6, 7],
[2, 3, 4, 5, 6, 7, 8],
[3, 4, 5, 2, 1, 4, 5],
[1, 2, 3, 4, 5, 6, 7],
[1, 2, 3, 4, 5, 6, 7]]),
array([[2.],
[3.],
[4.],
[3.],
[4.]]))
As you can see, while there might be duplicated rows in the resulting X
, the augmented rows [X | y]
are unique. I tried np.unique(np.hstack((X,y)))
, but this does not returns desirable results.