Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CategoricalIndex + and - should not be set operations? #10039

Closed
jorisvandenbossche opened this issue Apr 30, 2015 · 1 comment · Fixed by #10042
Closed

CategoricalIndex + and - should not be set operations? #10039

jorisvandenbossche opened this issue Apr 30, 2015 · 1 comment · Fixed by #10042
Assignees
Labels
API Design Categorical Categorical Data Type Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@jorisvandenbossche
Copy link
Member

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?)

@jorisvandenbossche jorisvandenbossche added Indexing Related to indexing on series/frames, not to indexes themselves API Design Categorical Categorical Data Type labels Apr 30, 2015
@jorisvandenbossche jorisvandenbossche added this to the 0.16.1 milestone Apr 30, 2015
@jreback
Copy link
Contributor

jreback commented May 1, 2015

yep, these are not defined so they get behavior from super-class. Ok, will whip something up. I agree TypeError is correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Categorical Categorical Data Type Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants