Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- df = pd.DataFrame({'A' : [5,6,3,4,6], 'B' : [1,2,3, 5,1]})
- list_of_values = [3,6]
- result= df.query("A in @list_of_values")
- print(result)
- A B
- 1 6 2
- 2 3 3
- 4 6 1
- A B
- 0 6 2
- 1 3 3
- 2 6 1
- df = pd.DataFrame({'A' : [5,6,3,4,6], 'B' : [1,2,3, 5,1]})
- list_of_values = [3,6]
- result= df.query("A in @list_of_values").reset_index(drop=True)
- print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement