0

From a data set consisting of 5 columns and containing an indefinite number of rows I would need to extract in an orderly manner the pairs of numbers that come out several times together in the same row, let me explain better with an example:

Suppose we have 5 columns called "First", "Second", "Third", "Fourth" and "Fifth" which contain numbers as in the following example.

| First | Second | Third | Fourth | Fifth |
|   50  |   12   |  81   |  47    |  78   |
|   47  |   64   |  9    |  12    |  87   |
|   81  |   50   |  47   |  64    |  12   |

In the example we see that, in the same row:

  • The number 47 is present together with the number 12 in total 3 times
  • The number 64 is present together with the number 47 in total 2 times
  • The number 47 is present together with the number 50 in total 2 times
  • The number 47 is present together with the number 81 in total 2 times
  • The number 47 is present together with the number 78 in total 1 times ecc...

Therefore the desired result will be to have the most frequent pairs of numbers ordered by number of frequency and not only for the single number (in this case 47) but for all those present in the table and also not to have "duplicates" (for example 47 -12 > 3 times , 12-47 > 3 times):

| First Number | Second Number | Frequency |
|      47      |       12      |     3     |
|      64      |       47      |     2     |
|      47      |       50      |     2     |
|      47      |       81      |     2     |
|      47      |       78      |     1     |

ecc...

I've made several attempts but I won't report them as I think they can only cause confusion

starball
  • 20,030
  • 7
  • 43
  • 238
Den
  • 1
  • 1

0 Answers0