过滤特定的记录和更早的使用窗口
我有数据框,例如
name nime | a | time |
---|---|---|
in | 中 | 2中的 |
a | 1 | 的 |
a | 3 | 中的a 3中的 |
a | 3 | in |
4 | in | b |
b | 4 | 1 in |
in | b 7 | in |
b | 7 in b 7 | in |
b | 18 in b 18 | in |
我只想在我最后一次拥有<<代码>法规 =“ out”和之后的行。像这样:
名称 | 时间 | 法规 |
---|---|---|
A | 4 | 中的a 4 |
a | 5 | 在 |
B | 7 | out |
b | 18 | in |
I have the dataframe like
name | time | statut |
---|---|---|
A | 1 | in |
A | 2 | out |
A | 3 | in |
A | 4 | out |
A | 5 | in |
B | 1 | in |
B | 4 | in |
B | 7 | out |
B | 18 | in |
I just want to get for each group the last time that I have statut
= "out" and the row after. Like this:
name | time | statut |
---|---|---|
A | 4 | out |
A | 5 | in |
B | 7 | out |
B | 18 | in |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可以使用几个窗口功能完成。但是,使用窗口的功能不是很简单。
结果:
最后一个过滤行之前的结果:
This can be done using a couple of window functions. However, the function which uses the window is not very simple.
Result:
Result before the last filter line: