I need help to change the structure to a pandas dataframe with many columns like the example:
original dataframe:
| xx | yy | zz | a | b | c | k |
|:---|:---|:---|:--|:--|:--|:--|
| x1 | y1 | z1 | 0 | 2 | 1 | 3 |
| x2 | y2 | z2 | 1 | 0 | 2 | 0 |
I need just the first 3 columns and change the rest
new dataframe:
| xx | yy | zz | valor | nueva columna|
|:---|:---|:---|:--|:--|
| x1 | y1 | z1 | 0 | a |
| x1 | y1 | z1 | 2 | b |
| x1 | y1 | z1 | 1 | c |
| x1 | y1 | z1 | 3 | k |
| x2 | y2 | z2 | 1 | a |
| x2 | y2 | z2 | 0 | b |
| x2 | y2 | z2 | 2 | c |
| x2 | y2 | z2 | 0 | k |
I get a solution with a for loop, but in colab when the columns and rows are many the time is excessive

DataFrame.melt.