1

I have a df.

>>>df = pd.DataFrame({"a": [1,2], "b": [3, 4], "c":[5, 6], 
"irrelevant": [7, 8], "do_not_use": [9, 10]})
>>> df
    a  b  c  irrelevant  do_not_use
 0  1  3  5           7           9
 1  2  4  6           8          10

I want to combine the columns a, b, c so I can get form

   value  type 
0    1     a
1    2     a
2    3     b 
3    4     b
4    5     c
5    6     c

Which I feel should be really easy but I cannot find a way to do it without big for loops and concatenation of series.

What is the best way to archive the transformation?

vahvero
  • 525
  • 11
  • 24

0 Answers0