【发布时间】:2019-08-10 00:06:13
【问题描述】:
我有四列数据,包括:Id、CreationDate、Score 和 ViewCount。
CreationDate 具有下一个格式,例如:2011-11-30 19:41:14.960。
我需要对CreationDate 的年份进行分组,计算它们,将Score 和ViewCount 相加,并添加到其他列中。
我想与 pandas 库一起使用。
谢谢!
更改之前 - 示例:
Id CreationDate Score ViewCount
0 1 2011-11-30 19:15:54.070 25 1526
1 2 2011-11-30 19:41:14.960 20 601
2 3 2012-11-30 19:42:45.470 36 1015
3 4 2018-11-30 19:44:55.593 8 1941
4 5 2011-11-30 19:53:23.387 11 5053
5 6 2018-11-30 20:04:43.757 25 5123
6 7 2011-11-30 20:08:23.267 53 8945
更改后 - 呈现这样的数据:
Id CreationDate Score ViewCount
0 1 2011 109 16125
2 3 2012 36 1015
3 4 2018 33 7064
【问题讨论】:
标签: python pandas numpy data-science data-analysis