I create a dataframe and categorize one column as intervals :
df_test = pd.DataFrame({'col': [0,1,2,3,4,5,6]})
df_test['cat']= pd.cut(df_test['col'],[-1.,0.,3.,10.])
df_test
col cat
0 0 (-1.0, 0.0]
1 1 (0.0, 3.0]
2 2 (0.0, 3.0]
3 3 (0.0, 3.0]
4 4 (3.0, 10.0]
5 5 (3.0, 10.0]
6 6 (3.0, 10.0]
Now I want to filter this dataframe using the cat column :
df_test[df_test['cat'] == pd.Interval(left=1., right=2.)]
col cat
1 1 (0.0, 3.0]
2 2 (0.0, 3.0]
3 3 (0.0, 3.0]
How come that checking equality with (1., 2.] yields this result ? I was expecting to get an empty result as that interval doesn't exist in the dataframe.
Am I supposed to filter using a different method ?