Background & Context

ArrayComponents gives an array in which all identical elements of an input array are replaced by an integer index (or "label") representing the component in which the element lies. The indices start at 1 and run consecutively through the number of distinct array elements. A special exception is that any occurrences of 0 and None are labeled with 0.

ArrayComponents works on lists, two-dimensional arrays, and arrays of arbitrary rank. It can be used to find identical elements at a specified level (e.g. rows in an array). Specific relabeling rules may also be specified.