13.12 Interconversion of rows and columns within a group

 

Here below is a data table:

imagepng

Now we want to convert the data to the following form:

imagepng

Script:

A
1 =‘Sheet1!A1:C8’
2 =A1.group@u(~(1))
3 =A2.(transpose(.(.to(2,))))
4 =A3.(~.(A2.(~(1)(1))(A3.#)|~)).conj()

A2: Group by the first column (Countries)
A3: Transpose the data in each group (except the country column)
A4: Concatenate the country and merge

The processing method described above is used for column-to-row conversion, this method works for row-to-column conversion as well.


esProc Desktop and Excel Processing
13.11 Rearrange multiple columns into a cross-tab
13.13 Interconversion of rows and columns in reverse order