It's already been asked, I was just searching the wrong terms.
The short answer is that chained relational operators such as 1 < a < 4
are expanded internally as (1 < a) and (a < 4)
. and
and or
cannot be overridden in Python -- see PEP335 and guido's post to the mailing list -- which means numpy can't use chained relational operators as masks. Thus, neither can Pandas.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…