>>> a = np.array([[1, 2], [3, 4]])
>>> b = np.array([[5, 6]])
>>> np.concatenate((a, b), axis=0)
array([[1, 2],
[3, 4],
[5, 6]])
>>> np.concatenate((a, b.T), axis=1)
array([[1, 2, 5],
[3, 4, 6]])
import numpy as np
arr = np.array([1, 2, 1, 2, 3, 4, 5, 4, 6, 7])
# create a set array with no duplicates
arr = np.unique(arr)
print(arr)
# [1 2 3 4 5 6 7]
arr1 = np.array([1, 2, 3, 4])
arr2 = np.array([3, 4, 5, 6])
# create a 1d set array without from both arrays removing duplicates
arr = np.union1d(arr1, arr2)
print(arr)
# output [1 2 3 4 5 6]
arr1 = np.array([1, 2, 3, 4])
arr2 = np.array([3, 4, 5, 6])
# create a 1d set array where both numbers are found in both arrays
arr = np.intersect1d(arr1, arr2, assume_unique=True)
print(arr)
# output [3 4]
arr1 = np.array([1, 2, 3, 4])
arr2 = np.array([3, 4, 5, 6])
# create a 1d set array that contained only numbers found in the first array but not the second
arr = np.setdiff1d(arr1, arr2, assume_unique=True)
print(arr)
# output [1 2]
arr1 = np.array([1, 2, 3, 4])
arr2 = np.array([3, 4, 5, 6])
# create a 1d set array where numbers from both arrays are not in each other
arr = np.setxor1d(arr1, arr2, assume_unique=True)
print(arr)
# output [1 2 5 6]