I have a simple pandas data frame.
import pandas as pd
x = [5, 10, 20, 30, 5, 10, 20, 30, 5, 10, 20, 30]
y = [100, 100, 200, 200, 300, 300, 400, 400, 500, 500, 600, 600]
users =['mark', 'mark', 'mark', 'rachel', 'rachel', 'rachel', 'jeff', 'jeff', 'jeff', 'lauren', 'lauren', 'lauren']
df = pd.DataFrame(dict(x=x, y=y, users=users)
I want to keep certain rows of the data frame. Let's say all "rachels" and "jeffs". I tried df.query
:
df=df.query('users=="rachel"' or 'users=="jeff"')
The result is a data frame only with users=="rachel"
. Is there a way to combine queries?