【问题标题】:Groupby transformation [duplicate]Groupby转换[重复]
【发布时间】:2018-06-29 14:43:50
【问题描述】:

这里我有按年份分组的电影,但我需要为每部电影分别填写一个年份值。

你能建议我怎么做吗?

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

谢谢!

【问题讨论】:

    标签: python pandas


    【解决方案1】:

    也试试这个。

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

    【讨论】:

      猜你喜欢
      • 2018-11-30
      • 2021-01-23
      • 2021-02-24
      • 2018-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-31
      • 2019-04-07
      相关资源
      最近更新 更多