I'm using pandas 0.24.2 and am unable to perform simple equality tests for Categorical instances. For example, with this code:
d = DataFrame({"x" : [1, 2, 3, 4]})
d["y"] = pd.cut(d["x"], bins=3)
The contents of d are now:
x y
0 1 (0.997, 2.0]
1 2 (0.997, 2.0]
2 3 (2.0, 3.0]
3 4 (3.0, 4.0]
However, I cannot test y for equality to string values, e.g.:
d["y"] == '(3.0, 4.0]'
Produces:
0 False
1 False
2 False
3 False
Name: y, dtype: bool
I get that the underlying type of y is Categorical, due to the output of cut(). However I cannot find any special methods for equality in the Categorical; moreover, the doc even states that "Equality comparisons work with . . . scalars." What am I missing in my approach?