I have the following DataFrame:
df_1 = DataFrame({
"alpha" : [1,1,1,2,2,2,3,3,3] ,
"beta" : [3,4,5,3,4,5,3,4,5] ,
"val_1" : ["x", "y" , "z", "w", "a", "b", "v1" , "v2" , "v3" ] ,
"val_2" : ["z1", "z2" , "z3", "w1", "w2", "w3" , "zz1" , "zz2" , "zz3" ]
})
df_1.set_index(["alpha", "beta"], inplace=True)
I am trying to select the following highlighted rows:
That is, every row where beta is either 3 or 5.
I have gone through the pandas documentation multiple times and cannot find a way to do this. The closest I've come to what I think must be the answer is:
df_1.xs((3,5), level="beta", drop_level=False)
Which now currently fails. What is the proper indexing/slicing way to get this?



Panel.