get_uniques_and_compacted#
- skrough.unique.get_uniques_and_compacted(values: ndarray) Tuple[ndarray, ndarray][source]#
Get unique values and compacted version of an input array.
Get unique elements (reported in ascending order) together with a compacted version of the input array
values. The compacted array is consisted of indices of the unique values that can be used to reconstruct the original array.- Parameters:
values – Input array.
- Returns:
Result is a 2-element tuple consisted of the following elements
unique values (reported in ascending order) of the input array
compacted version of the input array in the form of indices of unique values that can be used to reconstruct the original input array
Examples
>>> get_uniques_and_compacted(np.array([1, 2, 3])) (array([1, 2, 3]), array([0, 1, 2])) >>> get_uniques_and_compacted(np.array([3, 2, 1])) (array([1, 2, 3]), array([2, 1, 0])) >>> get_uniques_and_compacted(np.array([33, 11, 33, 33, 22])) (array([11, 22, 33]), array([2, 0, 2, 2, 1]))