I believe you need extra pair of parenthesis:
check[(check['effyear'] == '2020') &
(check['canceled'] == 'Y') &
(check['decile'] == 6) &
((check['usage'] == 'P') | (check['usage'] == 'S')) # () here
]
Also, use isin
for better syntax:
check[(check['effyear'] == '2020') &
(check['canceled'] == 'Y') &
(check['decile'] == 6) &
check['usage'].isin(['P', 'S']) # this
]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…