Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
df = pd.DataFrame({'P': range(1, 6),
                   'Q': range(10, 0, -2),
                   'R R': range(10, 5, -1)})
df
Out[2]:
P Q R R
0 1 10 10
1 2 8 9
2 3 6 8
3 4 4 7
4 5 2 6
In [3]:
df.query('P > Q')
Out[3]:
P Q R R
4 5 2 6
In [4]:
df[df.P > df.Q]
Out[4]:
P Q R R
4 5 2 6
In [5]:
import pandas as pd
df = pd.DataFrame({'P': range(1, 6),
                   'Q': range(10, 0, -2),
                   'R R': range(10, 5, -1)})
df.query('Q == `R R`')
Out[5]:
P Q R R
0 1 10 10
In [6]:
df[df.Q == df['R R']]
Out[6]:
P Q R R
0 1 10 10