如何根据列条件选择不同匹配组中的所有行
数据:
**A B C D**
101 1 1 FALSE
101 1 2 FALSE
101 1 3 FALSE
101 2 1 FALSE
101 2 2 FALSE
101 2 3 FALSE
101 2 4 TRUE
102 1 1 FALSE
102 1 2 FALSE
102 1 3 FALSE
102 2 1 FALSE
102 2 2 FALSE
102 2 3 TRUE
预期输出:
**A B C D**
101 2 1 FALSE
101 2 2 FALSE
101 2 3 FALSE
101 2 4 TRUE
102 2 1 FALSE
102 2 2 FALSE
102 2 3 TRUE
我需要B=(当D=True时B)的所有行
df.loc[df.groupby(["A"])[df_rvtlt['D'] == True]]
这里有一条从
transform
使用
any
IIUC,使用^{} +^{}
相关问题 更多 >
编程相关推荐