0

I have a dataframe with values of such structure:

df

metric_name  metric_type_1 metric_type_2 ...

metric_a     1             2           
metric_b     6             9             
metric_c     4             6            

I need to add a new column and change the orientation of the df, my ideal result is:

metric_name  metric_types   values

metric_a     metric_type_1   1 
metric_a     metric_type_2   2
metric_b     metric_type_1   6
metric_b     metric_type_2   9
metric_c     metric_type_1   4
metric_c     metric_type_2   6

I am not sure how could be this accomplished.

I have tried to add a blank column (df['values'] = None) and use df.T method but obviously it is a wrong approach.

Anna
  • 771
  • 7
  • 15

0 Answers0