So, I've been using the set method "symmetric_difference" between 2 ndarray matrices in the following way:
x_set = list(set(tuple(i) for i in x_spam_matrix.tolist()).symmetric_difference(
set(tuple(j) for j in partitioned_x[i].tolist())))
x = np.array([list(i) for i in x_set])
this method works fine for me, but it feel a little clumsy...is there anyway to conduct this in a slightly more elegant way?
A simple list of tuples:
put it in a set:
np.array
just wraps that set in an object dtype:but make it into a list, and get a 2d array:
Since it is a list of tuples, it can also be made into a structured array:
If the tuples varied in length, the list of tuples would be turned into a 1d array of tuples (object dtype):