# Determine different pairs

Let's create a sample data

data = {{0.21,0,0},{-3.2,2,1},{0.03,4,3},{3.1,0,0},{5.23,3,2},{8.02,1,1},{-2.4,2,1},{3.3,0,0},{1.02,1,1},{0.07,5,6}};


Each element of the list contains one real number and two integers. We are only interested in integers. We want to find how many different pairs of integers exist in the data list. In particular, we need to create a second list data2, containing all the different types in the form $$nm$$. For the above example, the list should be

data2 = {00, 21, 43, 32, 11, 56};


Any ideas?

• IntegerString[#, 10, 2] & /@ FromDigits /@ DeleteDuplicates[ Cases[#, _Integer] & /@ data] May 4, 2020 at 16:47

pairs = DeleteDuplicates @ (Rest /@ data)

{{0, 0}, {2, 1}, {4, 3}, {3, 2}, {1, 1}, {5, 6}}

ClearAll[f1, f2, f3]

f1 = Map[StringRiffle[#, ""] &] @ DeleteDuplicates @ #[[All, -2 ;;]] &;

f1 @ data

 {"00", "21", "43", "32", "11", "56"}

f2 = Map[FromDigits] @ DeleteDuplicates @ #[[All, -2 ;;]] &;

f2 @ data

 {0, 21, 43, 32, 11, 56}

f3 = Map[Row] @ DeleteDuplicates @ #[[All, -2 ;;]] &;
f3 @ data


• Well, how you remove the first column with the unwanted real numbers? May 4, 2020 at 16:42
• @Vaggelis_Z, Rest/@data removes the first column.
– kglr
May 4, 2020 at 16:43
• And if we want to remove the first four columns and leave the last two ones? May 4, 2020 at 16:44
• data[[All, -2;;]] is more general.
– kglr
May 4, 2020 at 16:47
• maybe #/Total[#] &@Counts[data[[All, -2 ;;]]] ?
– kglr
May 4, 2020 at 17:09