Q:

Remove duplicate tuples in numpy array (ones directly next to each other)

I am more or less new to python/numpy and I have this problem:
I have numpy arrays in which the first and last tuples are always the same.  In between, there are sometimes duplicate tuples (only the ones directly next to each other) that I want to get rid of.  The used parenthesis structure should be maintained. 
I tried np.unique already (e.g. 1, 2), but it changes my original order (which has to be maintained).  My sample array looks like this:
    myarray = np.array([[[1,1],[1,1],[4,4],[4,4],[2,2],[3,3],[1,1]]])

I need a result that looks like this:
    myarray = np.array([[[1,1],[4,4],[2,2],[3,3],[1,1]]])

Thank you in advance for your support! 

A:

Get the one-off offsetted comparisons along the second axis and use boolean-indexing to select -
myarray[:,np.r_[True,(myarray[0,1:] ! = myarray[0,:-1]).any(-1)]]

Sample run -
In [42]: myarray
Out[42]: 
array([[[1, 1],
        [1, 1],
        [4, 4],
        [4, 4],
        [2, 2],
        [3, 3],
        [1, 1]]])

In [43]: myarray[:,np.r_[True,(myarray[0,1:] ! = myarray[0,:-1]).any(-1)]]
Out[43]: 
array([[[1, 1],
        [4, 4],
        [2, 2],
        [3, 3],
        [1, 1]]])

Or with equality comparison and then look for ALL matches -
In [47]: myarray[:,np.r_[True,~((myarray[0,1:] == myarray[0,:-1]).all(-1))]]
Out[47]: 
array([[[1, 1],
        [4, 4],
        [2, 2],
        [3, 3],
        [1, 1]]])

