python - Count historical rows
问题描述
I have a dataframe which contains operations, and I want to add a column which give for each user the number of history of operations (number of rows with lower date)
user id date
1 2020-10-01
2 2020-11-02
3 2020-08-03
1 2020-09-25
3 2020-09-11
1 2020-09-26
3 2020-10-26
1 2020-10-05
2 2020-11-03
Output :
user id date Number of last operation
1 2020-10-01 2
2 2020-11-02 0
3 2020-08-03 0
1 2020-09-25 0
3 2020-09-11 1
1 2020-09-26 1
3 2020-10-26 2
1 2020-10-05 3
2 2020-11-03 1
解决方案
推荐阅读
- twitter-bootstrap - 如何提高引导按钮“越过”拉伸的链接?
- visual-studio - 使用 Visual Studio 2017 和 Visual Studio 2019 设置和使用 Specflow、Selenium、Nunit、.NET Core 的步骤
- angular - 如何在组件模板中重用 HTML 块?
- ios - 添加多个单元格时,UICollectionViewCell 未正确对齐
- laravel - Laravel 5.8 419 错误/登录后身份验证用户不可用
- swiftui - 升级到 iOS13 beta 6/Xcode 11 beta 5 后:发出“dyld: Symbol not found: _$s7SwiftUI7BindingVyxGAA0C11ConvertibleAAMc”
- javascript - 我不确定我是在滥用 SwitchNavigator 还是只是遗漏了一些东西
- thingsboard - 如何对齐标题文本?
- javascript - 如何使用不和谐机器人返回变量
- xamarin - 标签与控件不对齐