0

This seems rather obvious, but I can't seem to figure out how to convert column index of data frame to value?

For example:

From:

enter image description here

To:

enter image description here

  • You'll have to be more specific, i don't understand what you want to do. Also, please post code to show us what you've tried. – Capie Dec 17 '20 at 12:55
  • Use `df = df.stack().rename_axis([None, 'Y']).rename('W').reset_index(level=1)` – jezrael Dec 17 '20 at 12:57
  • https://stackoverflow.com/questions/28654047/pandas-convert-some-columns-into-rows This answer is just what I want. use df.melt(). Thank you too! – Cambridge Lv Dec 18 '20 at 01:29

0 Answers0