0

I know the title sounds confusing. But let me explain with an example. I have date vise data of covid cases in states of India.

The data is of the below form

enter image description here

I want it to be like

Final

Each date can have new state names based of if those states got new cases. So for each date the data can have varied number of states name as per first image.

EXODIA
  • 908
  • 3
  • 10
  • 28

1 Answers1

2

You could use pandas.DataFrame.pivot:

df.pivot(index='Date', columns='Name', values='Numbers')
Jonas
  • 1,749
  • 1
  • 10
  • 18