get_uniques_and_positions#
- skrough.unique.get_uniques_and_positions(values: ndarray) Tuple[ndarray, ndarray][source]#
Get unique elements of an array and indices of first occurrences of these values.
Get unique elements (reported in ascending order) of the input array
valuesalong with the positions/indices in the input array for which unique values appear for the first time.- 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
position/indices in the input array for which unique values appear for the first time
Examples
>>> get_uniques_and_positions(np.array([2, 7, 1, 8, 2, 8, 1])) (array([1, 2, 7, 8]), array([2, 0, 1, 3])) >>> get_uniques_and_positions(np.array([3, 3, 2, 1, 3])) (array([1, 2, 3]), array([3, 2, 0])) >>> get_uniques_and_positions(np.array([1, 3, 3, 2])) (array([1, 2, 3]), array([0, 3, 1]))