0

I have a dataframe like below, the row number is identical with all XX YY ZZ variables,

Name date    Value 
XX   01/20     69
XX   02/20     75
YY   01/20     450
YY   02/20     430
ZZ   01/20     1000
ZZ   02/20     899

how to convert it into

date      XX   YY   ZZ 
01/20     69  450   1000
02/20     75  430   899

You notice that value column is gone, and all values became observations under XX YY ZZ Features.

anky
  • 74,114
  • 11
  • 41
  • 70
Sambou988
  • 3
  • 2
  • 1
    Welcome to stack overflow. Please input dataframes as actual text, rather than images. Makes it easier for others to copy+paste. – warped Jun 17 '20 at 15:31

1 Answers1

0

you can use pivot:

df.pivot(index='date', columns='Name', values='Value')
warped
  • 8,947
  • 3
  • 22
  • 49