最好的是
boolean indexing但需要反转条件-使所有值相等且更高,如下所示
72:
print (df[df["coverage"] >= 72]) coverage name reports yearPima 214 Molly 24 2012Santa Cruz 212 Tina 31 2013Maricopa 72 Jake 2 2014Yuma 85 Amy 3 2014
与
ge功能相同:
print (df[df["coverage"].ge(72)]) coverage name reports yearPima 214 Molly 24 2012Santa Cruz 212 Tina 31 2013Maricopa 72 Jake 2 2014Yuma 85 Amy 3 2014
另一种可能的解决方案是通过
~以下方法反转掩码:
print (df["coverage"] < 72)Cochice TruePima FalseSanta Cruz FalseMaricopa FalseYuma FalseName: coverage, dtype: boolprint (~(df["coverage"] < 72))Cochice FalsePimaTrueSanta Cruz TrueMaricopa TrueYumaTrueName: coverage, dtype: boolprint (df[~(df["coverage"] < 72)]) coverage name reports yearPima 214 Molly 24 2012Santa Cruz 212 Tina 31 2013Maricopa 72 Jake 2 2014Yuma 85 Amy 3 2014



