1 回答

TA貢獻1795條經驗 獲得超7個贊
為每個記錄創建一個標志,以便您可以groupby-all輕松地確定組中的所有標志是否都為 true(sta在您的情況下)。隨后,sta可以使用 選擇具有限定值的行df.isin()。
df["flag"] = (df["pbias"] > 100) & (df["pcorr"] < 0.2)
sr_sta = df.groupby("sta")["flag"].all()
# qualified sta's
sta_yes = sr_sta.index.values[sr_sta]
ans = df[df["sta"].isin(sta_yes)]
輸出
print(ans)
sta exp pbias pcorr pcorr_anom kge flag
2 2 a04d 3857.0583 0.1138 0.1138 -51.5705 True
6 2 a04e 504.9175 -0.0676 -0.0676 -6.0067 True
10 2 a04f 596.7894 0.0608 0.0608 -5.7271 True
14 2 a04g 440.5116 0.0694 0.0694 -3.8980 True
18 2 a04h 393.3018 0.0318 0.0318 -3.0665 True
添加回答
舉報