df
| a | b |
|----|---|
| 10 | 1 |
| 10 | 5 |
| 11 | 1 |
直接使用
grouped = df.groupby('a')
让我们只获得
selector = grouped.b.max() - grouped.b.min() >= 3
屈服
df
| a | |
|----|-------|
| 10 | True |
| 11 | False |
我的问题是,当使用DataFrameGroupBy
元素时df = df.loc[<filter condition>]
的等价物是什么
在基于.aggreate()
函数进行过滤时,是否有办法保留组?谢谢
遗憾的是,我没有找到一个直接的解决办法。。所以我用2
groupby
解决了这个问题:对于
df.loc[]
等价的问题,您可以执行以下操作:或者(内部联接解决方案):
产出:
PS+1@rafaelc-用于
.ptp
事情您可以使用^{} (峰到峰)
相关问题 更多 >
编程相关推荐