Skip to content
Advertisement

Transpose a single column in DF

The table I have

JavaScript

The transpose I want to do is single column transpose

index name value batchnumber
0 Result 1 255.00 59534
1 Result 2 260.00 59534
2 Result 3 285.00 59534
3 Result 1 255.00 59530
4 Result 2 260.00 59530
5 Result 3 325.00 59530

I tried pivot

JavaScript

Advertisement

Answer

You can pivot_wider then melt. In this case, you get the same results but rather unmatched rows

JavaScript

You could sort before you melt:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement