concatenate and remove duplicate element from numpy arrays
You can use numpy.concatenate
and numpy.unique
:
In [81]: arr = np.array([ 1, 6, 56, 120, 162, 170, 176, 179, 197, 204])
In [82]: arr = np.unique(np.concatenate((arr, np.array([ 29, 31, 56, 104, 162, 170, 176, 179, 197, 204]))))
In [83]: arr
Out[83]: array([ 1, 6, 29, 31, 56, 104, 120, 162, 170, 176, 179, 197, 204])
you can concatenate arrays first with numpy.concatenate
then use np.unique
import numpy as np
a=np.array([1,6,56,120,162,170,176,179,197,204])
b=np.array([29,31,56,104,162,170,176,179,197,204])
new_array = np.unique(np.concatenate((a,b),0))
print new_array
result:
[ 1 6 29 31 56 104 120 162 170 176 179 197 204]