0

Here I have films grouped by year, but I need to have a year value filled for each film respectively.

Could you please suggest how can I do that?

cast.groupby(['year','name']).size()

year  name                
1894  Blanche Bayliss         1
      Chauncey Depew          1
      William Courtenay       1
1900  Orrie Perry             1
      Reg Perry               1
1905  Armand Dranem           1
1906  Battling Nelson         1
      E.J. Tait               1
      Elizabeth Tait          1
      Frank (VI) Mills        1
      Frank Tait              1
      Helfrid Lambert         1
      Jack (II) Ennis         1
      Joe Gans                1
      John (III) Forde        1
      John Tait               1
      Knut Lambert            1
      Mr. Marshall            1
      Mr. McKenzie            1
      Norman (II) Campbell    1
      Sam Crewes              1
      Tollie Zellman          1
      Will Coyne              1
1907  Arthur Guest            1

Thanks!

Tom Cheng
  • 19
  • 6

1 Answers1

1

Also try this.

cast.groupby(['year','name']).size().reset_index()
Tai
  • 7,684
  • 3
  • 29
  • 49