[英]Listing a dataframe organised into months with nunique and Max() of other features [closed]
页面总赞数 | 类别 | 发布月 |
---|---|---|
139441 | 2 | 12 |
139441 | 2 | 12 |
139441 | 3 | 12 |
139441 | 2 | 12 |
139441 | 2 | 12 |
我有一张像上面这样的桌子。 我试图在每个月的列表中获得每个类别 (1-3) 的最高页面总赞数,写成 1-12
.apply(list)
.groupby(level=0)
.apply(np.cumsum)
.apply(lambda x: len(set(x)))
.reset_index(name='cumulative_module_count'))```
gives me a list without the grouping nor maximum likes
My result should be a multi-dimensional list example:
[Month, 1, Category, 1, Page total likes,139441],[Month, 1, Category, 2, Page total likes,124958],[Month, 1, Category, 3, Page total likes,109441],[Month, 2, Category, 1, Page total likes,129441],[Month, 2, Category, 2, Page total likes,199441],...[Month, 12, Category, 3, Page total likes,129441]
The above shows a list where each month(1-12) expressed for each Category (1-3) identifying the max likes for that given category in that month.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.