Lets imagine a pandas dataframe table like (in sql the keys would be [type, product]):
| type | product | ... | a1 | a2 | a3 | a4 |
|---|---|---|---|---|---|---|
| 0 | 0 | ... | a | b | c | d |
| 0 | 1 | ... | e | f | g | h |
| 0 | 2 | ... | i | j | k | l |
| 0 | ... | ... | m | n | o | p |
| 0 | n | ... | q | r | s | t |
| 1 | 0 | ... | ... | ... | ... | ... |
| 1 | 1 | ... | ... | ... | ... | ... |
| 1 | 2 | ... | ... | ... | ... | ... |
| 1 | ... | ... | ... | ... | ... | ... |
| 1 | n | ... | ... | ... | ... | ... |
| 2 | 0 | ... | ... | ... | ... | ... |
| 2 | 1 | ... | ... | ... | ... | ... |
| 2 | 2 | ... | ... | ... | ... | ... |
| 2 | ... | ... | ... | ... | ... | ... |
| 2 | n | ... | ... | x | y | z |
what I need as output is :
| type | product | a index | a value |
|---|---|---|---|
| 0 | 0 | a1 | a |
| 0 | 0 | a2 | b |
| 0 | 0 | a3 | c |
| 0 | 0 | a4 | d |
| 0 | 1 | a1 | e |
| 0 | 1 | a2 | f |
| 0 | 1 | a3 | g |
| 0 | 1 | a4 | h |
| ... | ... | .... | .... |
| 2 | n | a4 | z |
So, transposing the rows from a1-a4 for every row and combining it with the keys.
Is this possible and if how.
Thanks