CategoricalIndex + and - should not be set operations? · Issue #10039 · pandas-dev/pandas (original) (raw)
Related with the issue I just opened (#10038), I relooked at the set operation deprecation issues we had before (xref #8227, #9095, #9630).
To make a summary:
- in 0.15.0 we deprecated set operations, only for new TimedeltaIndex it is already numeric operation
- in 0.15.1, for numeric indexes this was by accident converted to numeric operation
- in 0.16.0, explicit deprecation added for DatetimeIndex
- in a future release we want to have it all numeric operations (or TypeErrors if the dtype does not support that operation)
But now, for the CategoricalIndex added, it is a set operation again (but with a warning):
In [1]: idx = pd.Index(pd.Categorical(['a', 'b']))
In [2]: idx
Out[2]:
CategoricalIndex([u'a', u'b'],
categories=[u'a', u'b'],
ordered=False,
name=None)
In [3]: idx - idx
c:\users\vdbosscj\scipy\pandas-joris\pandas\core\index.py:1191: FutureWarning: u
sing '-' to provide set differences with Indexes is deprecated, use .difference(
)
"use .difference()", FutureWarning)
Out[3]: Index([], dtype='object')
As this is a new index, we should at once use the correct behaviour?
(Which is raising a TypeError I think?)