import pandas as pd
df = pd.DataFrame()
df["col1"] = range(4)
df["col2"] = list(range(2)) * 2
# 多条件 代替 if query
cond = '''
(col1 == 0 and col2 == 0) or \
(col1 == 1 and col2 == 1)
'''
res = df.query(cond)
print(res)
import pandas as pd
df = pd.DataFrame()
df["col1"] = range(4)
df["col2"] = list(range(2)) * 2
# 多条件 代替 if query
cond = '''
(col1 == 0 and col2 == 0) or \
(col1 == 1 and col2 == 1)
'''
res = df.query(cond)
print(res)