Code Sample, a copy-pastable example if possible

dtw[(x <= dtw.id < y)]

Expected Output

same as dtw[(x <= dtw.id) & (dtw.id < y)] or dtw.query('{}<=id<{}'.format(x, y)), but these solutions are less Pythonic

Comment From: jorisvandenbossche

This is a limitation of the Python language itself, nothing pandas can do about (numpy arrays have the same limitation). The problem is that (x <= dtw.id < y) expands to (x <= dtw.id) and (dtw.id < y), but the and can only handle booleans and will not work elementwise on arrays/Series as & does.

Comment From: TomAugspurger

One place we do have control over it is inside .query, where dtw.query('@x <= id < @y') works like you expected.